Commit Graph

15 Commits

Author SHA1 Message Date
Jenny Messerly 00f27a32cf [dartdevc] fix NSM with private field overrides and mixin declarations
Analyzer does not put mixin declarations in the `.types` getter, which
broke DDC's assumption that it contained all of the class/interface
types in the compilation unit. Kernel backend was not affected.

Change-Id: I219d814766fb97ef81920d0150cb1dfbbc6087f5
Reviewed-on: https://dart-review.googlesource.com/c/82022
Auto-Submit: Jenny Messerly <jmesserly@google.com>
Commit-Queue: Alan Knight <alanknight@google.com>
Reviewed-by: Alan Knight <alanknight@google.com>
2018-10-30 16:52:25 +00:00
Daniel Hillerström 5d1832b20a Disallow factory constructors in mixin declarations.
Signal a compile-time error if a mixin declaration contains a factory
constructor (regardless of whether it is redirecting). Note, this only
applies to _mixin declarations_, derived mixin classes can still
contain factory constructors.

Closes https://github.com/dart-lang/sdk/issues/34804

Change-Id: I713b623316664ea360f896789d8e619ad6f07ca5
Reviewed-on: https://dart-review.googlesource.com/c/80100
Commit-Queue: Daniel Hillerström <hillerstrom@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-10-17 05:44:46 +00:00
Johnni Winther 41a875f420 Fix (super)mixins issues
Change-Id: I5892f2fec7fc7b7449fb600c74e4d105dc0f4bbe
Reviewed-on: https://dart-review.googlesource.com/77180
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-09-28 23:03:24 +00:00
Paul Berry c22b2efb48 Verify that mixin constraints can't be satisfied by the application (or named class) itself.
When I first began working on the feature I mistakenly thought that
these two test cases would be free from compile-time errors, so it
seemed like it would be worth adding a test case to make sure others
don't have the same misunderstanding.

Change-Id: I322991c818f9d136180de443090fa4e15f6f0e27
Reviewed-on: https://dart-review.googlesource.com/76680
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2018-09-26 13:07:04 +00:00
Leaf Petersen 33f6c8ef35 More super mixin tests.
Test mixin class definition syntax, and test that inference is not
performed in the on clause of a mixin.  Bug fixes.

Change-Id: I01679c4eb556d9c7bd9227b5d3a79293a027706c
Reviewed-on: https://dart-review.googlesource.com/75622
Reviewed-by: Paul Berry <paulberry@google.com>
2018-09-21 19:21:23 +00:00
Leaf Petersen b7f762923e Add tests for more super invocation edge cases
Change-Id: Ideee02c85bd2704419378dec01de452bc143d1b0
Reviewed-on: https://dart-review.googlesource.com/75785
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-09-21 00:52:13 +00:00
Jenny Messerly 64b6d713e3 [dartdevc] enable super mixin support in Kernel backend
Change-Id: If2a1c4ec8328080a890e7f22b657b19af4fe53ae
Reviewed-on: https://dart-review.googlesource.com/75791
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Jenny Messerly <jmesserly@google.com>
2018-09-20 23:59:18 +00:00
Paul Berry 296e4aa7e6 Split mixin_declaration_inference_valid_classes_test.dart into multiple tests.
I will soon start landing fixes to address some (but not necessarily
all) of the test cases in this test, and I want to make sure that my
fixes produce corresponding status file changes, to secure against
possible future regressions.

Change-Id: Iaec11b85a20d670c0702220cadbbdfc51c026d1f
Reviewed-on: https://dart-review.googlesource.com/75624
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-09-20 00:04:42 +00:00
Leaf Petersen d4148159cc Initial valid inference checks
Change-Id: I75c3f3a4072aeaa6f27d399196ba3c57e79fecbb
Reviewed-on: https://dart-review.googlesource.com/74017
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2018-09-18 19:59:26 +00:00
Konstantin Shcheglov a27bafc306 Check that the concrete member in the class has same type as the super-invoked member in the mixin.
R=brianwilkerson@google.com

Change-Id: I985872d2eb5eaf7608b030b9803d664ad0878b04
Reviewed-on: https://dart-review.googlesource.com/75243
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-09-18 17:06:22 +00:00
Jenny Messerly 0496569f09 implement super mixins in dartdevc and fix a few issues in Analyzer
Fixes #34167. This implements the Dart 2 mixin proposal
(https://goo.gl/KEKQyv) for DDC. When the mixin is applied, a class
is created for the application that extends the correct superclass
and has all of the instance members, so `super` works correctly.

This also fixes a few minor issues in Analyzer's (mostly complete)
implementation:
- InterfaceType.isObject now returns false for Dart 2 mixins.
- Least upper bound calculation recognizes mixins are not Object.
- Interface of the mixin now implements its superclass constraints.
- Mixin superclass constraints are checked against the superclass and
  all previously applied mixins (if any); this keeps it working with
  the subtype fix above, and also prevents a not-yet-applied mixin
  from satisfying the constraint

The language_2/mixin_declaration tests were updated with a few minor
fixes now that we can run Analyzer/dartdevc to test them.

This change implements super mixins for DDC's Kernel backend (DDK)
too. This will be enabled once Kernel adds a flag to recognize which
Class nodes are mixins (vs normal classes).


Change-Id: Ib3c4fcb12de9988345e52d92931196828d8227c3
Reviewed-on: https://dart-review.googlesource.com/74965
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
2018-09-18 03:21:48 +00:00
Bob Nystrom a16c7d899a Fix typo in mixin test.
Change-Id: I1c6300dfa250ef0b9ea84e9bd5fd233eb5827464
Reviewed-on: https://dart-review.googlesource.com/74960
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2018-09-14 05:18:39 +00:00
Lasse Reichstein Holst Nielsen 9ab03ce3a3 Remove spurious full stops after "compile-time error"
Change-Id: Ia8d99c2f4de70480c449aa72fde637f07d401288
Reviewed-on: https://dart-review.googlesource.com/74120
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-09-11 11:36:22 +00:00
Kevin Millikin cbfc78f5b2 Parse mixin declarations as if they were classes
In Fasta's outline builder, parse mixin declarations as if they were
the corresponding class declaration:

mixin M<T0,...,Ti> on S0,S1,...,Sj implement I0,...,Ik {...}

is parsed as if it were:

class M<T0,...,Ti> extends S0 with S1,...,Sj implements I0,...,Ik {
  ...
}

This supports the syntax and should automatically provide an
implementation of the runtime semantics on the VM.  Not all of the
required static checks are implemented in the front end.

Change-Id: Ice65e93446222484272f8f7db0de2d18c352f56b
Reviewed-on: https://dart-review.googlesource.com/73760
Reviewed-by: Dan Rubel <danrubel@google.com>
2018-09-10 20:40:45 +00:00
Lasse Reichstein Holst Nielsen 68b6bbc3ac Add tests for new mixin declaration syntax.
The tests are not exhaustive, but they can hopefully be a good start when implementing the feature.

The test are not *checked* since there is currently no implementation of the feature, or even the syntax.
They should be expected to contain some errors.

Bug: https://github.com/dart-lang/language/issues/7
Change-Id: I4a5364566aeba9de036e56ae188205337575154c
Reviewed-on: https://dart-review.googlesource.com/70509
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-09-07 06:54:49 +00:00