Commit Graph

3034 Commits

Author SHA1 Message Date
Dan Rubel bec3801a02 Improve recovery when mixin app missing "with" clause
Change-Id: I81849a973f1033f271b39de851c6335cae63377f
Reviewed-on: https://dart-review.googlesource.com/49241
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-04-03 20:45:19 +00:00
Dan Rubel 701e02b2fa Update AstBuilder to handle named function declaration
Change-Id: I34e699e49b7138b6d0ecf7087afef9739888c716
Reviewed-on: https://dart-review.googlesource.com/49240
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-04-03 20:45:19 +00:00
Dan Rubel 57d6ec265d Improve AstBuilder for-in recovery
Fix AstBuilder recovery when for-in expression is not a simple identifier

Change-Id: Id32ec4f8054de7870d8424c489dc5f5819ec7632
Reviewed-on: https://dart-review.googlesource.com/49181
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-04-03 18:08:29 +00:00
Dan Rubel ca7edd065c Improve invalid function body recovery
* Improve error message for use of "return" instead of "=>"
* Improve recovery given extraneous "return" after "=>"

Change-Id: I0e421ece1128f98b883b6c9110f1a5eaaced3d78
Reviewed-on: https://dart-review.googlesource.com/49180
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-04-03 17:31:39 +00:00
Dan Rubel 1daa81339f Improve fasta parser enum declaration recovery
In addition to improving recovery when an enum declaration is missing
a body, this CL also fixes ensureBlock to report an error on the
correct token and cleans up some more analyzer tests.

Change-Id: I96e9f8380b8d92082d94fcc9fa4b8cfe113fa238
Reviewed-on: https://dart-review.googlesource.com/48980
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-04-02 17:55:14 +00:00
Brian Wilkerson 616acb06ec Deprecate the option to enable using a URI in a part-of directive
Change-Id: Ie9df0d727c0f81c9671ccedf5ba4d21cdbbe65b8
Reviewed-on: https://dart-review.googlesource.com/48892
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-04-02 16:25:04 +00:00
Dan Rubel 374058aa79 Improve fasta parser try/catch error messages and recovery
Change-Id: I6e591fa5d03c73aa6f3e8060f2ca310f68be9a78
Reviewed-on: https://dart-review.googlesource.com/48709
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-04-01 02:14:52 +00:00
Jenny Messerly bed5debbeb Callable object support in Analyzer and DDC.
Fixes #32156
Fixes #32157
Fixes #32426

This also fixes `implements Function` so it has no effect in Dart 2
(it is ignored for the purposes of subtyping.)

Change-Id: Ibec9c77cd516b8b97fef68a579998598d0acf8c6
Reviewed-on: https://dart-review.googlesource.com/45141
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
2018-03-30 18:14:55 +00:00
Paul Berry 506ac7f953 Rework linker type inference using ExprBuilder.
This CL changes the way linker type inference works.  Instead of
walking the operations in an UnlinkedExpr in order and inferring types
directly, it first builds an AST for the expression using ExprBuilder,
then uses ResolverVisitor to resolve the AST and perform type
inference.

This helps ensure that summary type inference and ordinary AST-based
type inference produce the same result, since they now use the same
core algorithm.  In particular, this means that summary type inference
now does downwards inference properly.

Since the ResolverVisitor makes greater use of the element model than
the rest of the linker, this required implementing additional methods
in the linker's element model.

This CL includes some minor fixes to ExprBuilder that were uncovered
during testing.  It also contains some minor changes to
ResolverVisitor to make it work during linking.

Fixes #32525.
Fixes #32394.

Change-Id: I5ec9b2bf5565ad30b8cc856475334323dc118da8
Reviewed-on: https://dart-review.googlesource.com/48741
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-03-29 17:16:39 +00:00
Dan Rubel e260a01272 Replace skipTypeReferenceOpt with computeType part 1
This CL modifies class member parsing to replace one use of skipTypeReferenceOpt
and parseType with a more efficient call to computeType. In addition, it updates
computeType to detect when a builtIn is used as a type and improves recovery
of invalid operator declarations.

Change-Id: Idbe96584ef3c2e72faf91037668421bb0f1055d0
Reviewed-on: https://dart-review.googlesource.com/48221
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-25 20:03:34 +00:00
Dan Rubel 6180f12ccf Update parsing as/is expressions to use computeType
This introduces a new TypeInfo.ensureType method which recovers
when a type is required but there is no type.

Change-Id: Ie9080864f814329bc7a7dcdf73440fd184e9e0f8
Reviewed-on: https://dart-review.googlesource.com/47944
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-23 17:58:59 +00:00
Dan Rubel 20b9b541ae Improve recovery when parsing type arguments
Change-Id: I4eea9a7ddff809a7cf0c3ea430f408449228514f
Reviewed-on: https://dart-review.googlesource.com/48024
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-23 15:05:00 +00:00
Dan Rubel 721e29e552 Cleanup statement parsing and tests
Change-Id: I107ce5f3b6ebac123198b9a3a471f0a52cdcf1e3
Reviewed-on: https://dart-review.googlesource.com/48020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-23 14:54:39 +00:00
Dan Rubel 7450e2ad60 Fix parsing of invalid interpolation in string literal
Change-Id: I7151cee5f97a5a43314885326e4806a0314af544
Reviewed-on: https://dart-review.googlesource.com/47582
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-03-22 18:50:13 +00:00
Brian Wilkerson 26c06cdd82 Clean up Dart 2 type issues related to YAML support
Change-Id: Ic29054afca9773286aa899eecede287f7ecbca9a
Reviewed-on: https://dart-review.googlesource.com/47680
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-03-22 17:06:40 +00:00
Dan Rubel 04f5d1b974 Recover from missing while in do/while statement
Change-Id: Ifa63dd07cc2468b6339b29a3afcf6b01058e1866
Reviewed-on: https://dart-review.googlesource.com/47860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-22 15:50:57 +00:00
danrubel 8136c957a1 Improve fasta parser library declaration recovery
This CL extracts recovery for invalid library names into a new
subclass of IdentifierContext. This same approach will be used in
subsequent CLs to improve error messages and recovery when parsing
identifiers in other situations.

Change-Id: I03987f4e4bbe0f61f88adb3028a87e41d7dc7eb3
Reviewed-on: https://dart-review.googlesource.com/47541
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-21 20:39:05 +00:00
Dan Rubel 587e4f8723 Parse local function metadata
Change-Id: I6b578b295e645cf270126de93b03232acd302101
Reviewed-on: https://dart-review.googlesource.com/47400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-03-21 14:21:09 +00:00
Dan Rubel d26c310a27 Rework parsing of local const declarations
Similar to earlier work that reworked parsing of variable declarations,
this CL reworks parsing of local constant declarations to use
TypeInfo rather than parseType. This simplifies and improves recovery,
and reduces the number of error messages in some recovery situations.

Change-Id: I32705bdba20a0cb7aee41c64510c4c2896a5ae68
Reviewed-on: https://dart-review.googlesource.com/47241
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-20 22:50:20 +00:00
Brian Wilkerson 0e764393f3 A few more Dart2 related fixes
Change-Id: If2503b93e11f0831787dfa21e5ae0abb74e9162f
Reviewed-on: https://dart-review.googlesource.com/47302
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-03-20 20:17:59 +00:00
danrubel 08d305bbd7 Inline modifiers into endTopLevelFields and endFields events
Change-Id: I9681e22ae96c43626558ff567cbf4a12117095fa
Reviewed-on: https://dart-review.googlesource.com/47240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-20 15:00:35 +00:00
Dan Rubel adb9f8cc0b Inline modifiers into beginClassDeclaration and beginNamedMixinApplication
Change-Id: I0d95029c203a77d4a9e9dc2d8f1b40bced7535c5
Reviewed-on: https://dart-review.googlesource.com/47186
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-20 13:28:17 +00:00
Dan Rubel fd005e17bc Rework parsing of local function declarations
This CL reworks parsing local variable and local function
declarations to improve recovery and error messages.
In addition, the fasta parser properly parses metadata
before a local function declaration.

Change-Id: Ia43c8bab3f3ce3b824390a4aa36d50b85f1ea9af
Reviewed-on: https://dart-review.googlesource.com/46952
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-03-20 12:01:26 +00:00
Dan Rubel 06949dc985 Inline modifiers into beginFactoryMethod event
Change-Id: Ibc1053126b020577625279f4fab0bcff71aa5d15
Reviewed-on: https://dart-review.googlesource.com/47182
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-19 22:04:37 +00:00
Dan Rubel 8fde515354 Inline modifiers into beginTopLevelMethod event
Change-Id: I40423fcd53dc6a374a1c5be280d1806c31f34a6d
Reviewed-on: https://dart-review.googlesource.com/47120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-19 20:20:37 +00:00
Konstantin Shcheglov 538dbb62d6 Don't expect type arguments for class type parameters of static methods.
R=brianwilkerson@google.com

Bug: https://github.com/dart-lang/sdk/issues/32396
Change-Id: I4b6b6804cfced4c6628198a7e99e0123f77c2108
Reviewed-on: https://dart-review.googlesource.com/46940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-03-19 17:03:15 +00:00
Brian Wilkerson 1560f19844 Fixes to make analyzer preview-dart-2 safe, part 1 of many
Change-Id: I8f88168a1fab61b3d0d808b5d9e09e6391325302
Reviewed-on: https://dart-review.googlesource.com/46953
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-03-19 13:15:46 +00:00
Konstantin Shcheglov c9cb9c6700 Infer type arguments in constructor redirections.
R=brianwilkerson@google.com

Bug: https://github.com/dart-lang/sdk/issues/30855
Change-Id: I05e9102fe7b7a304be6ac6dd4d59e11bdafee59c
Reviewed-on: https://dart-review.googlesource.com/46575
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-03-15 19:37:45 +00:00
Brian Wilkerson e9cdb5d4a8 Convert more analyzer tests to pass under preview-dart-2
Change-Id: Id2c7069da725db2d2572507fb73b51f5ab574d8a
Reviewed-on: https://dart-review.googlesource.com/46571
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-03-15 17:25:54 +00:00
Brian Wilkerson 8819d9fe98 Update analyzer tests for preview-dart-2, part 1
Change-Id: I3440607f7b3892193e1d9883709a1b9d4a7463d9
Reviewed-on: https://dart-review.googlesource.com/46562
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-03-15 16:45:04 +00:00
Dan Rubel 71e16622cd Improve for statement errors and recovery
This CL updates fasta parsing of `for` statements
to detect additional errors and improve recovery.

The parser originally called parseType when parsing `for` statements
which committed the parser down a particular path
and limited the ability of the caller to gracefully recovery.
Now the parser calls computeType, which parses and caches
the type information, so that the caller has more opportunity
to recover gracefully.

Change-Id: I6296ffb1f75e77a87a7533bfca77dae18cfcf60d
Reviewed-on: https://dart-review.googlesource.com/46383
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-15 11:43:13 +00:00
Dan Rubel 55369c5ed6 Report error on "as void" and "is void"
Change-Id: I1835d2f2c9ff6a4eac21adb3cac3c03e1f613e00
Reviewed-on: https://dart-review.googlesource.com/46640
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-15 11:42:53 +00:00
Brian Wilkerson 5eb6d980b5 Do not hint when using a deprecated parameter in the defining function (issue 32468)
Change-Id: I71de5c121add7bca7faa0875573e27f17f672e44
Reviewed-on: https://dart-review.googlesource.com/45840
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-03-09 19:09:08 +00:00
Brian Wilkerson 602a8c2a7b Clean up usage of deprecated constants
Change-Id: I9005ba6e94529e15d8f7b21322591f4a9dabec47
Reviewed-on: https://dart-review.googlesource.com/45763
Commit-Queue: William Hesse <whesse@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-03-09 01:02:49 +00:00
Dan Rubel 83c8c21abe Gracefully handle local function modifiers
Change-Id: I23f5ab9c9aaaee595ab6c552a6dddf9522ee17cd
Reviewed-on: https://dart-review.googlesource.com/45400
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-03-07 12:47:31 +00:00
Leaf Petersen 7fe8bdb2ee Refactor tests
Change-Id: I29caa5421d9a2d25726aaaf676fd319b595dde7f
Reviewed-on: https://dart-review.googlesource.com/44880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-03-07 01:57:31 +00:00
Brian Wilkerson 69f8d4ef0d Fix parsing of super expressions (issue 32393)
Change-Id: I887288254eb1be33c111b6dedd16c2acd3eb3dd1
Reviewed-on: https://dart-review.googlesource.com/45440
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2018-03-07 00:43:21 +00:00
Paul Berry b5b8080b2c Disable the conflicting generics check when using the old task model.
This is necessary since the old task model doesn't implement mixin
type inference properly.

Works around bug #32421.

Change-Id: I6d7873d658d9d0fd8ea6aa5d2452bf9e92947032
Reviewed-on: https://dart-review.googlesource.com/45200
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-03-06 14:14:54 +00:00
Brian Wilkerson 5fd560f96b Add getters to replace ParameterKind
Change-Id: I0886c8d032e963857b8054e894ed3343a235b5c2
Reviewed-on: https://dart-review.googlesource.com/44921
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-03-05 14:22:52 +00:00
Brian Wilkerson 0b332de3a8 Refactor where AST re-writing is happening to not interact poorly with inference (issue 32342)
Change-Id: Ia8c0d17cedb78709dce421658eb46ff6a80d56c5
Reviewed-on: https://dart-review.googlesource.com/44384
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-03-05 14:22:02 +00:00
Paul Berry 2993476129 Report an error if a class inconsistently implements a generic interface.
This is not allowed in Dart 2.0.

Change-Id: I6861ce298e5d5a5cf3f26a010990868b5ba9bda2
Reviewed-on: https://dart-review.googlesource.com/39601
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-03-05 12:13:12 +00:00
Paul Berry 11cbdbe26e When checking mixin type inference errors, don't skip mixins with explicit type args.
Fixes #32372.

Change-Id: I77bcdcdb5a764ba1d6075176800fa038aa46a1f9
Reviewed-on: https://dart-review.googlesource.com/44440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-03-05 09:10:01 +00:00
Dan Rubel e74e2b3c3e Pass varFinalOrConst in beginVariablesDeclaration event
This CL refactors the fasta parse variable declaration functionality
to pass the modifier with the begin event rather than using the
handleModifer and handleModifiers events.

* Refactor modifier parsing as described above
* Update same modifier parsing to use ModifierRecoveryContext2
* Cleanup functionality of ModifierRecovery2
* Remove 2 unused fasta parser methods

Change-Id: Ib3a6b24428dcf6ad3cb462a979a05600fe7ee673
Reviewed-on: https://dart-review.googlesource.com/44860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-03 21:51:31 +00:00
Dan Rubel 22f860a229 Update AstBuilder to report illegal assignment
Change-Id: Ic65fdc6274e73e20b2230048855ef1025548aa5b
Reviewed-on: https://dart-review.googlesource.com/44820
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-02 21:10:59 +00:00
Dan Rubel fe8eb7a402 Update some analyzer fasta integration tests
Change-Id: If479bb6c52e3ba6c8deadf20d16e484d4e7d96d3
Reviewed-on: https://dart-review.googlesource.com/44640
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-01 22:16:28 +00:00
Dan Rubel 590d85876e Report "missing statement" error on void
Also address comments in
https://dart-review.googlesource.com/c/sdk/+/42800

Change-Id: I0fa1a61d1ec9a5a0db0d9d672ab8b436004980b5
Reviewed-on: https://dart-review.googlesource.com/44620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-01 21:04:48 +00:00
Dan Rubel 989a3bfc23 Report error on invalid use of super
Change-Id: I361e88714a3221d947e4e90ed44df2bbcc8b6ec3
Reviewed-on: https://dart-review.googlesource.com/44562
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-03-01 18:54:48 +00:00
Dan Rubel 1065da5b34 Report error on duplicate label in switch statement
Change-Id: I4df8e6baf4dc7c14dd900a7212c3b6eda55a861b
Reviewed-on: https://dart-review.googlesource.com/44560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-03-01 16:52:58 +00:00
Paul Berry b1a5325171 Suppress "extends" check when inferring mixins.
This should be safe since the purpose of the inference is to find an
exact match for each type parameter; if an exact match is found but it
doesn't satisfy the "extends" constraint, that will be detected and
reported later.  If an exact match isn't found, the type bound will be
filled in my instantiate-to-bounds.

Addresses the analyzer portion of issue #32353.

Change-Id: Ic9f71eefac2fa3f6f126957b9d1652ca1d990b89
Reviewed-on: https://dart-review.googlesource.com/44220
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-03-01 05:55:26 +00:00
Dan Rubel 7ddeb32ec7 Update fasta parser to report error on "=" in for-in loop
In addition, this CL
* Inlines parseVariablesDeclarationOrExpressionOpt
* Adds for statement missing parenthesis recovery
* Removes TypeContinuation.VariablesDeclarationOrExpression
    and inline the functionality

Change-Id: Ied57eb35848026ab856f21c66283bc8883a9d5e1
Reviewed-on: https://dart-review.googlesource.com/44360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-28 21:22:34 +00:00