Commit Graph

4770 Commits

Author SHA1 Message Date
Dan Rubel b3847560e4 Update AstBuilder to report interpolation in import conditional
Change-Id: If87831a138c14ef913f46b99b044c774d828ea08
Reviewed-on: https://dart-review.googlesource.com/44080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-27 23:29:07 +00:00
Kevin Millikin 13067387a4 Fix mixin inference for classes read from .dill files
When classes are loaded from a VM-specific .dill file, mixin
applications have been translated into normal classes.  In that case
the mixin class will be found as the only implemented type.

Change-Id: I6543f1e0bad72d351efb0a768f2c9c8967b8a196
Reviewed-on: https://dart-review.googlesource.com/43965
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2018-02-27 20:09:58 +00:00
Dan Rubel 700732786b Remove type argument on dynamic check from parser
Change-Id: I1c92e311a931f5bf0768352c2b066559a8d7b339
Reviewed-on: https://dart-review.googlesource.com/43920
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-02-27 18:12:58 +00:00
Dan Rubel 6f710ee546 Update AstBuilder to report scanner errors
Change-Id: I7b33a86378a7c816ccdfb1a7e0869ccd5c3b8f7c
Reviewed-on: https://dart-review.googlesource.com/43900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-27 17:20:58 +00:00
Dmitry Stefantsov e7830a9f7b Add a flag to Procedures indicating that it's a redirecting factory
Fixes #32282

Bug: http://dartbug.com/32282
Change-Id: Iee8535b053ced415e3047e990a0940d859faa86a
Reviewed-on: https://dart-review.googlesource.com/43440
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-27 10:42:07 +00:00
Paul Berry 0d42430ed8 Change the implicit tear-off of call methods to be null-aware.
We want the implicit tear-off of a `call` method to succeed even if
the value is `null`, so we need the implicit tear-off to be equivalent
to `?.call`.

Change-Id: I5134858b84e501081a52d59b78b101597bdfcc4a
Reviewed-on: https://dart-review.googlesource.com/43480
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-02-27 09:44:27 +00:00
Dan Rubel 76cd43ab02 Update fasta parser listeners to generate additional errors
This updates the AstBuilder and OutlineBuilder
to generate the following errors:

* ConstConstructorWithBody
* ConstMethod
* ConstructorWithReturnType
* FieldInitializerOutsideConstructor

In order to get the necessary state in OutlineBuilder so that I could
report these errors, I extracted SourceLibraryBuilder.addConstructor
from addProcedure.

In addition, I updated AstBuilder to use handleRecoverableError
rather than parser.reportRecoverableError.

Change-Id: I8b5517ec2ab44ff13a65628c594f803138cad6f5
Reviewed-on: https://dart-review.googlesource.com/43800
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-26 19:48:25 +00:00
Aske Simon Christensen 69775fbf8c Allow constructors called 'get' or 'set'.
Closes https://github.com/dart-lang/sdk/issues/32196

Change-Id: I61ea62b5c3d96634b1830383217ba6ef2aef8b7b
Reviewed-on: https://dart-review.googlesource.com/43741
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
2018-02-26 17:30:17 +00:00
Aske Simon Christensen bb088347f0 Separate severity for context messages
Change-Id: I8c0f9f0eae141e38e1f57afce4a30b6f95e8e412
Reviewed-on: https://dart-review.googlesource.com/43721
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2018-02-26 16:24:13 +00:00
Peter von der Ahé 790a34b9f0 Provide lengths in more cases
Change-Id: I76f629528329dbd1de90a8a415d03aa0f1975113
Reviewed-on: https://dart-review.googlesource.com/43520
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2018-02-26 10:27:54 +00:00
Dan Rubel a8be36f42a Report error on dynamic with type arguments
Change-Id: Ie95e1c1b0b23cb3a3b6d4b7b7561edc2765fdebb
Reviewed-on: https://dart-review.googlesource.com/43560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-23 21:49:07 +00:00
Dan Rubel d2a16738be Error when type is omitted from function type parameter
Change-Id: Ia124235b348bd1dcec7162c7968976b2adec0a1f
Reviewed-on: https://dart-review.googlesource.com/42680
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-02-23 19:03:06 +00:00
Peter von der Ahé 09777d2179 Move Arguments to Forest
Change-Id: Ic3617a1aaa63729722bdf506dd4f1b8977046623
Reviewed-on: https://dart-review.googlesource.com/43041
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-23 18:51:46 +00:00
Peter von der Ahé 595b599001 Prefer tokens over int offsets
Change-Id: I057721c8b84484b434247276aead319885c90447
Reviewed-on: https://dart-review.googlesource.com/41800
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2018-02-23 18:08:04 +00:00
Kevin Millikin 7ea40d281c Do not expect named parameters to be sorted
The code for checking overrides seemed to assume that named parameters
were sorted, but they are not.

Fixes https://github.com/dart-lang/sdk/issues/32283

Change-Id: I2775201ecfa79f9968e554a166d2fee79f011063
Reviewed-on: https://dart-review.googlesource.com/43460
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-02-23 17:26:26 +00:00
Dan Rubel a8bf40399f Update fasta parser to report error on static constructor
This refactors how modifiers are passed to listener so that the
OutlineBuilder can report a static constructor error.

* Remove handleModifier/s calls from parseMethod
* Pass name and modifiers in beginMethod event
* Update listeners to process method modifiers in beginMethod event
    * AstBuilder
    * NodeListener
    * OutlineBuilder
* Address comment in https://dart-review.googlesource.com/c/sdk/+/42800

Change-Id: Iabd4a18613c1814eb5a157df4acf60dd9060d5eb
Reviewed-on: https://dart-review.googlesource.com/43120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-23 13:18:46 +00:00
Peter von der Ahé 4304a50ef6 Move all literals to tree factory
Change-Id: I34e3b5a03d60031fe80892cc5c8153ca47f1f298
Reviewed-on: https://dart-review.googlesource.com/41780
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2018-02-23 11:41:14 +00:00
Mike Fairhurst ea37af3e71 Change dynamic to void to be compliant with #32161
Change-Id: Ic986525d61bc36fb5ad25cacb2c9233b75c38bf7
Reviewed-on: https://dart-review.googlesource.com/42322
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-02-22 21:46:41 +00:00
Jens Johansen e8026c1e76 [fasta] Fix crash on dynamic<argument>
Change-Id: Ibebb7bc5b95979cef9254305430b55ce8cb3cb34
Reviewed-on: https://dart-review.googlesource.com/42744
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-02-22 14:06:03 +00:00
Dmitry Stefantsov 22447b9516 Fix bug in assignability check for return expressions of async bodies
Change-Id: Iaab2466ac1c9766861e72e9224a3206da6c42d45
Reviewed-on: https://dart-review.googlesource.com/42743
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-22 13:15:14 +00:00
Dmitry Stefantsov b94da9dbe7 Run instantiate-to-bound tests in legacy mode
Change-Id: I6cc90caea40b210f6a988a3c019f3ebc900a7a42
Reviewed-on: https://dart-review.googlesource.com/42640
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-02-22 12:37:53 +00:00
Peter von der Ahé 7deea026b3 Include length in problems
Change-Id: Ieaf7e1445da2b4974f7a325d74186b4b4f2eb72b
Reviewed-on: https://dart-review.googlesource.com/42840
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
2018-02-22 11:44:38 +00:00
Dan Rubel f008b41d6b Parse invalid top level blocks during recovery
* New handleInvalidTopLevelBlock event for analyzer recovery
* Extract parseInvalidBlock and override in diet parsers

This addresses comments in https://dart-review.googlesource.com/c/sdk/+/41100

Change-Id: Ia7a7cc490231f5569906e4ad54c451c3b92c1e6b
Reviewed-on: https://dart-review.googlesource.com/42800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-21 19:06:19 +00:00
Peter von der Ahé d359ce8650 Replace \n in expectation files with newline
Change-Id: Ia8444f7b817ac8e298c4f212f7aaa4fc6ba026b7
Reviewed-on: https://dart-review.googlesource.com/42682
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2018-02-21 17:02:07 +00:00
Kevin Millikin be30b62e3d Remove the Kernel type inference listener
We have decided to move to a different API for Fasta/Analyzer
integration, one that doesn't involve compiling to Kernel or observing
type inference.  The listener API will become broken, so let's just
remove it before that happens.

We lose the ability to trace type inference so let's restore that
ability next.  The analyzer's resolution storer is not used, but that
code has been left.  The resolution applier will no longer work
without the resolution storer, so those tests have been disabled.

Change-Id: If9ac5aba2d5de7788d8a65f7fa8410599e636d21
Reviewed-on: https://dart-review.googlesource.com/42400
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-02-21 16:28:07 +00:00
Paul Berry b119f7a4cd Only allow implicit use of .call if it refers to a method.
Change-Id: I4c332b64eb7338ceaf63544c3dd0317f8c7d4538
Reviewed-on: https://dart-review.googlesource.com/42020
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-21 14:12:14 +00:00
Dmitry Stefantsov cdd228510b Move computeStrongComponents utility to pkg/kernel
Change-Id: I5f8f87875b8d65859dcbb21c74586c842389d9d1
Reviewed-on: https://dart-review.googlesource.com/42440
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-02-21 12:02:04 +00:00
Jens Johansen bd94ab5068 [kernel] Test bootstapping from dill with deferred library
This CL adds a test that bootstraps from a dill with a deferred library
in it. Before this CL it crashed, see bug #32245.

This CL "double fixes" the problem:
a) When lazy loading a dill file the _currentLibrary variable wasn't set
   properly. This has been fixed.
b) When bootstrapping from a dill file, (almost) everything in the dill
   will be included in the output so lazy loading it doesn't make sense.

Bug: 32245.
Change-Id: I94980608e19633fd31b522651a4a05b9cf7beabd
Reviewed-on: https://dart-review.googlesource.com/42600
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-21 09:39:24 +00:00
Peter von der Ahé 26437741ec Fix crash in handleType
Closes https://github.com/dart-lang/sdk/issues/32200

Change-Id: I3f35d3c5cbc7ab3e0e098bf8e2d3ed695f068b97
Reviewed-on: https://dart-review.googlesource.com/41984
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
2018-02-20 17:10:17 +00:00
Aske Simon Christensen 2183869465 Treat invocations on dynamic as unknown, except for return type of ==
Closes https://github.com/dart-lang/sdk/issues/32173

Change-Id: I77bd06f292a701f1b51d4077f31439598a7b4683
Reviewed-on: https://dart-review.googlesource.com/41762
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2018-02-20 16:42:25 +00:00
Aske Simon Christensen 194dcf6a9b Report detailed errors when the number or names of arguments do not
match parameters of callee.

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

Change-Id: Ic53cc55174a540f387289d4d9cc24ff5c65c547e
Reviewed-on: https://dart-review.googlesource.com/40822
Reviewed-by: Paul Berry <paulberry@google.com>
2018-02-20 16:42:25 +00:00
Jens Johansen 60cf51f8a2 [fasta] Fix bootstrapping from dill when library has disappeard
When bootstrapping from an existing dill file, the incremental compiler
tries to create a bit-perfect output in the case where nothing has
changed (even if something had been marked as changed).
To do this it has to ensure that the order of the libraries doesn't
change. The previous implementation of this just inserted a library with
the same url as before at the exact same index as in the original dill
file which works fine (and is linear time) in the case where there are
no old libraries that dissappear. When for instance the first library
disappear, though, things go awry.

This CL introduces a test for it and fixes the issue by simply sorting
the libaries based on the original placement instead.

Fixes #32197.

Bug: 32197
Change-Id: I57bf20d7b8ec9232844d52d9e3a28cad474a5311
Reviewed-on: https://dart-review.googlesource.com/42401
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-02-20 14:32:15 +00:00
Paul Berry 6e3b91507b Use getCalleeType to look up the type of an implicitly invoked .call method.
This ensures that if the class containing the `.call` method is
generic, the appropriate substitutions will be made.

Fixes #32238.

Change-Id: Ie72ebffc8f3a8233a7e4d7f9cec1d5fd7b2eec97
Reviewed-on: https://dart-review.googlesource.com/42380
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-02-20 12:14:14 +00:00
Dmitry Stefantsov 629bef0a91 Apply special rules to assignability check for async bodies
Fixes #32185

Bug: http://www.dartbug.com/32185
Change-Id: I07d35679d08c4aef38029b83f0d495cf05a02366
Reviewed-on: https://dart-review.googlesource.com/41940
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2018-02-16 20:14:18 +00:00
Peter von der Ahé 2191139a1a Fix crash in mixin canonicalization
Change-Id: Ifcb15672816aae04833c18fa6954336e680ddda7
Reviewed-on: https://dart-review.googlesource.com/41820
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
2018-02-16 09:00:16 +00:00
Peter von der Ahé 3c773f68bc Start on a tree factory to abstract AST node creation
Change-Id: I3db98c2f7eaa93a0df6ff848fb57d5b7e4cd2482
Reviewed-on: https://dart-review.googlesource.com/41681
Reviewed-by: Paul Berry <paulberry@google.com>
2018-02-15 15:13:29 +00:00
Jens Johansen 00c9af8522 [fasta] Fix crash when importing nonexisting "dart:" uri
Previously, importing a nonexisting "dart:" uri resulted in a crash in
fasta. This CL introduces a test and fixes the problem.

Fixes #31172.

Change-Id: I61b2668466f2567e5e5dcaff3203f0c5ee9a885f
Reviewed-on: https://dart-review.googlesource.com/36401
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-02-15 14:00:17 +00:00
kmillikin b019045393 Front-end implementation of mixin type inference.
Infer missing type arguments to generic mixin classes in mixin
applications based on mixin supertype constraints.  The implementation
directly follows the draft feature specification at
https://dart-review.googlesource.com/c/sdk/+/38940.

Bug: https://github.com/dart-lang/sdk/issues/31984
Change-Id: I7caba037b1b0e73c44f71aaa958f3ff3e8f3c1f0
Reviewed-on: https://dart-review.googlesource.com/40661
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-02-14 22:43:24 +00:00
Dmitry Stefantsov ec9c927b18 Resolve type arguments of redirecting factories invocations
Fixes #32068

Change-Id: Ifc2c832d5a761ae51b7f93084543aa04902a9529
Reviewed-on: https://dart-review.googlesource.com/40280
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-14 22:03:23 +00:00
Dan Rubel dd0a08a75e Improve fasta parser error reporting
This CL updates the fasta parser to report more errors
and have improved recovery. The new errors reported include:

* IllegalAssignmentToNonAssignable
* MissingAssignableSelector
* StaticConstructor

In addition, a number of test expectations were updated
to match the errors already produced by the fasta parser.

Change-Id: I99889e8e64663ca5b81a5d5d8f5e5241d049a0a2
Reviewed-on: https://dart-review.googlesource.com/41100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-02-14 18:01:14 +00:00
Paul Berry c4de71ede2 Re-land "Change front_end handling of callable classes."
Original description:
Change front_end handling of callable classes.

This CL is the first in a series of CLs to change the handling of
callable classes in Dart 2.0.

For purposes of this description, a "callable class" is a class whose
interface contains a `.call` method.

In Dart 1.0, a callable class was considered to be a subtype of the
`.call` method's function type.  This allowed the user to create
custom objects with similar behavior to closures, but with additional
fields and methods.

In Dart 2.0, a callable class is just an ordinary class, with no
subtype relation to any particular function type.  (Note however that
it is still permissible for a class to declare that it "implements
Function").

To reduce the amount of code broken by this change, a piece of
syntactic sugar is being added: if an expression whose static type is
a callable class appears where a function type is expected, an
implicit tear-off of the `.call` method is inserted.

Note that it is still possible at compile time to invoke an expression
whose static type is a callable class, and it is still possible at
runtime to invoke an expression whose runtime type is a callable
class; in both cases, this is considered an implicit invocation of the
class's `.call` method.  This is unchanged from Dart 1.0 behavior.

This CL introduces test cases for the new behavior, and implements the
implicit tear-off of `.call` in the front end.

Still to be implemented in future CLs:

- Spec text needs to be written.

- DDC/analyzer code needs to be written to perform implicit tear-offs
  of `.call`.

- The subtyping algorithm in DDC, analyzer, VM, and dart2js needs to
  be changed so that callable classes are no longer considered
  subtypes of any particular function type.

- A small corner case involving type parameters still needs to be
  addressed (see TODO in
  pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart).

Fixes #32064.

Change-Id: I0d397c608321e25ba42cc02aa8a516aa77aa7c9d
Reviewed-on: https://dart-review.googlesource.com/41280
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-02-14 15:22:25 +00:00
Paul Berry e2bdbb8bb8 Revert "Change front_end handling of callable classes."
This reverts commit f0a6330db0.

Reason for revert: Broken bots

Original change's description:
> Change front_end handling of callable classes.
> 
> This CL is the first in a series of CLs to change the handling of
> callable classes in Dart 2.0.
> 
> For purposes of this description, a "callable class" is a class whose
> interface contains a `.call` method.
> 
> In Dart 1.0, a callable class was considered to be a subtype of the
> `.call` method's function type.  This allowed the user to create
> custom objects with similar behavior to closures, but with additional
> fields and methods.
> 
> In Dart 2.0, a callable class is just an ordinary class, with no
> subtype relation to any particular function type.  (Note however that
> it is still permissible for a class to declare that it "implements
> Function").
> 
> To reduce the amount of code broken by this change, a piece of
> syntactic sugar is being added: if an expression whose static type is
> a callable class appears where a function type is expected, an
> implicit tear-off of the `.call` method is inserted.
> 
> Note that it is still possible at compile time to invoke an expression
> whose static type is a callable class, and it is still possible at
> runtime to invoke an expression whose runtime type is a callable
> class; in both cases, this is considered an implicit invocation of the
> class's `.call` method.  This is unchanged from Dart 1.0 behavior.
> 
> This CL introduces test cases for the new behavior, and implements the
> implicit tear-off of `.call` in the front end.
> 
> Still to be implemented in future CLs:
> 
> - Spec text needs to be written.
> 
> - DDC/analyzer code needs to be written to perform implicit tear-offs
>   of `.call`.
> 
> - The subtyping algorithm in DDC, analyzer, VM, and dart2js needs to
>   be changed so that callable classes are no longer considered
>   subtypes of any particular function type.
> 
> - A small corner case involving type parameters still needs to be
>   addressed (see TODO in
>   pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart).
> 
> Fixes #32064.
> 
> Change-Id: I6a86491047ae467a5e767cb3cc7cecb570b29308
> Reviewed-on: https://dart-review.googlesource.com/40508
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Kevin Millikin <kmillikin@google.com>
> Reviewed-by: Leaf Petersen <leafp@google.com>
> Reviewed-by: Erik Ernst <eernst@google.com>

TBR=paulberry@google.com,lrn@google.com,leafp@google.com,dmitryas@google.com,eernst@google.com,kmillikin@google.com

Change-Id: Ia3d3a6e46ceee2b2c55938bec95d09d50bbf06a7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/41240
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-02-14 13:10:54 +00:00
Paul Berry f0a6330db0 Change front_end handling of callable classes.
This CL is the first in a series of CLs to change the handling of
callable classes in Dart 2.0.

For purposes of this description, a "callable class" is a class whose
interface contains a `.call` method.

In Dart 1.0, a callable class was considered to be a subtype of the
`.call` method's function type.  This allowed the user to create
custom objects with similar behavior to closures, but with additional
fields and methods.

In Dart 2.0, a callable class is just an ordinary class, with no
subtype relation to any particular function type.  (Note however that
it is still permissible for a class to declare that it "implements
Function").

To reduce the amount of code broken by this change, a piece of
syntactic sugar is being added: if an expression whose static type is
a callable class appears where a function type is expected, an
implicit tear-off of the `.call` method is inserted.

Note that it is still possible at compile time to invoke an expression
whose static type is a callable class, and it is still possible at
runtime to invoke an expression whose runtime type is a callable
class; in both cases, this is considered an implicit invocation of the
class's `.call` method.  This is unchanged from Dart 1.0 behavior.

This CL introduces test cases for the new behavior, and implements the
implicit tear-off of `.call` in the front end.

Still to be implemented in future CLs:

- Spec text needs to be written.

- DDC/analyzer code needs to be written to perform implicit tear-offs
  of `.call`.

- The subtyping algorithm in DDC, analyzer, VM, and dart2js needs to
  be changed so that callable classes are no longer considered
  subtypes of any particular function type.

- A small corner case involving type parameters still needs to be
  addressed (see TODO in
  pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart).

Fixes #32064.

Change-Id: I6a86491047ae467a5e767cb3cc7cecb570b29308
Reviewed-on: https://dart-review.googlesource.com/40508
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2018-02-14 11:03:32 +00:00
Dmitry Stefantsov 83c33372bf Apply instantiate to bound to raw types in supertypes
Change-Id: I29226b158f0cb2f98ad54e1f2e6e8cd481e7a1cb
Reviewed-on: https://dart-review.googlesource.com/40900
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2018-02-13 22:41:01 +00:00
Vyacheslav Egorov 964d6379c2 Fix conditionEndOffset for asserts with messages.
Previously the everything between parentheses was considered as condition which
is incorrect.

This fixes test failures on Flutter test/foundation/error_reporting_test.dart.

Change-Id: Icce41f0fbb44e38d2f49b60dfc0dc52881d2e4d2
Reviewed-on: https://dart-review.googlesource.com/40521
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-02-12 17:57:24 +00:00
Samir Jindel 63c7c158de Fix conditional imports/exports in IKG.
Change-Id: If05656934b0ee9e195bc0a1f4060c000681fb93a
Reviewed-on: https://dart-review.googlesource.com/39988
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-02-12 15:27:04 +00:00
Dan Rubel df77ee3474 Refactor parseInitializer
Change-Id: I7c5b0ebddeb7dabaa0f3e6c5976ba4d9553f950a
Reviewed-on: https://dart-review.googlesource.com/40440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-10 15:50:39 +00:00
danrubel 87a395bd09 Allow "Function" as prefixed identifier
Change-Id: Id8dd154d8e3426a9a01d548af94d413e97590c76
Reviewed-on: https://dart-review.googlesource.com/40320
Reviewed-by: Dan Rubel <danrubel@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-09 15:41:10 +00:00
Peter von der Ahé c580897aec Implement Fasta batch compiler to interface with test.dart
Change-Id: Ic946fe771350dcc792df944d4dae13a69b8c6cf1
Reviewed-on: https://dart-review.googlesource.com/36621
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-02-09 15:29:49 +00:00
Dan Rubel d4f2f9cef2 Update fasta parser to report constructor initializer errors
This CL updates the fasta parser to report three additional
errors in constructor initializers:

* ExpectedAnInitializer
* MissingAssignmentInInitializer
* RedirectingConstructorWithBody

I also added a comment from a discussion about
https://dart-review.googlesource.com/c/sdk/+/39320

Change-Id: Iecb6fe97e3612a11ccc89864a4fc9f353846504c
Reviewed-on: https://dart-review.googlesource.com/40040
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-02-08 18:08:40 +00:00