This is another step to replacing parseType with computeType
and improving recovery when parsing types and type arguments.
This adds a new computeTypeParamOrArg utility which returns
one of a couple constants for common situations or an instance
of ComplexTypeParamOrArg. The computeType function and
some places in ComplexTypeInfo class have been updated to use
this new method, but there are additional places that will be
tackled in subsequent methods.
Change-Id: I7012b65580e9dbc74b9424456262aa3c0367f48b
Reviewed-on: https://dart-review.googlesource.com/53641
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
Also fix the type inference algorithm so that when it explores
multiple alternatives (as a result of the use of FutureOr<>), if one
alternative generated some constraints but failed to produce a match,
it rewinds those constraints and tries the other alternative.
(Previously, it erroneously assumed that if any constraints were
generated, the alternative matched successfully).
Also add unit tests to verify the proper operation of the subtype
match algorithm.
Fixes#32305.
Change-Id: I060b5d6d5247a68d2b27bba78819bae172e43d97
Reviewed-on: https://dart-review.googlesource.com/53685
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Jenny Messerly <jmesserly@google.com>
We needed bytes only to get their length.
This CL replaces it to using the content (String) length.
This should help to fix heap usage regression.
R=paulberry@google.com
Change-Id: I4d58e91987db21233a71ca600eea8fae3fb38346
Reviewed-on: https://dart-review.googlesource.com/53243
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
The performance I see is similar to using functions.
R=brianwilkerson@google.com
Change-Id: Ib5f675f07b422bd9e6f28df0f9d7ea8b24669f63
Reviewed-on: https://dart-review.googlesource.com/52881
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Based on https://dart-review.googlesource.com/c/sdk/+/52340, but adds
the necessary plumbing through the test system to pass through
negations to strong and preview-dart-2. Also adds support for those
negations to the analyzer.
Change-Id: I9793ff28bb593d25bbb0a2ed8736b5b53e0a62d8
Reviewed-on: https://dart-review.googlesource.com/52461
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This makes the Flutter repo analysis about 6% faster.
Before: 56.9 57.4 56.9 57.3 56.5 56.9 56.6
After: 53.5 53.0 53.8 54.3 53.5 53.0 53.0
To see the different better, I ran lints 100 and 10 times for each file.
Before: 628 621 109 107 109
After: 338 333 77 75 76
To get these numbers we will need to make corresponding changes to lints,
to implement these interfaces, so that they are used instead or the
current visitors. I have these changes locally, but we would need to
publish analyzer first.
R=brianwilkerson@google.com, pquitslund@google.com
Change-Id: I8b4efe05f815082fe39c33c303bb92b7dac19f65
Reviewed-on: https://dart-review.googlesource.com/52644
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
... and update more analyzer tests
Change-Id: Ieed123e16e7ae451cf2046253deb0c7773091417
Reviewed-on: https://dart-review.googlesource.com/52500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
When recovering from an invalid annotation in a type variable
(e.g. "< @Foo.bar T >"), the parser could get stuck in an
infinite loop trying to recover. This fixes that situation.
Change-Id: If01e43b9eec575824329808eeb93437432830654
Reviewed-on: https://dart-review.googlesource.com/52300
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
I see however that linter/test/rule_test.dart uses it, but as far as I
can see, that's it. All other usages are from analyzer and
analysis_server.
R=brianwilkerson@google.com
Change-Id: I2b82870a4a4ec6f155326d8ee6dc1c1028f84793
Reviewed-on: https://dart-review.googlesource.com/52265
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
One thing to be careful of here is that function type bounds may be
left unbounded. However, their parameters and return type cannot refer
to a type parameter for resolve-to-bounds to work.
There are also a large number of ways that this can loop infinitely, and
a number of new guards had to be added (as well as some test cases) to
catch them all.
Change-Id: I14322f5f71d1f7b73b27a870553e5c588b2c7e2e
Reviewed-on: https://dart-review.googlesource.com/52062
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This improves recovery when parsing conditional import expressions
by repositioning the synthetic closing ')' that was inserted by the
scanner in a less than optimal location.
This approach relies on the beforeSynthetic field being set correctly.
While the scanner still sets the 'next' and 'beforeSynthetic' fields
directly for efficiency, most other functions which update an existing
token stream have been revised to call 'setNext()' rather than setting
the 'next' field directly. This ensures that the 'beforeSynthetic' field
will be correctly updated.
Change-Id: Id631fd600c64d1feaf00593acb74a7070e354f07
Reviewed-on: https://dart-review.googlesource.com/52120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This CL improves recovery given invalid or malformed formal parameter
types and identifiers. This accomplished by switching the
parseFormalParameter method to use computeType rather than parseType,
improving recovery when parsing field initializers, and in the process,
further reducing the size of parseType and eliminating 6 unused
TypeContinuation elements.
Change-Id: I6f05d8018bf8d9f2c256e5a64408c29db006a8e2
Reviewed-on: https://dart-review.googlesource.com/52000
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This reverts commit 7cc55d0372.
Reason for revert: More test fixes needed.
Change-Id: Ib36159184ffbd14ce3f7cca184ce2b8cdfec237c
Reviewed-on: https://dart-review.googlesource.com/51680
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Similar to https://dart-review.googlesource.com/51442, we compute
export namespaces recursively and remember full export namespaces
when there are no cycles.
This makes Flutter analysis about 8% faster.
Before: 59.8 60.0 59.4
After: 55.2 55.3 55.1 55.6 55.4
R=brianwilkerson@google.com, devoncarew@google.com
Change-Id: Id78aae1ff475e4386e5a01a01b92f0768a0cd4aa
Reviewed-on: https://dart-review.googlesource.com/51582
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This CL updates the beginFormalParameters event to include
the covariant and const/final/var modifiers, and cleans up
a number of unused classes and methods including:
* the original implementation of ModifierContext/Recovery
* handleModifier and handleModifiers events
Change-Id: Ie89a202d17872fba85cd1a477091472a8d2d223b
Reviewed-on: https://dart-review.googlesource.com/51380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
Instead of chasing exports in each FileState library individually, we
perform recursive computation, and remember computed export namespaces
for visited branches. Cycles require special handling - we don't
remember partial namespaces, we compute one full export namespace and
so break the cycle; then the rest also can be computed in one pass.
This makes Analysis Server a bit faster for some Quick Fixes, and
what is more important, is a playground to test the idea of makeing
the similar change to _Prelinker. We spend 8% of total analysis time
chasing long chains of exports in Flutter.
R=brianwilkerson@google.com, devoncarew@google.com
Change-Id: Ia45cff9a7fb24aac2e72fe50752274b764462017
Reviewed-on: https://dart-review.googlesource.com/51442
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
isAssignableTo should check for subtype first, and it should only check
for a call method if the other side accepts a function type.
Also improves performance of the recursive guard checking: function
types should not need it (pruning takes care of that), so we can simplify
the code for interface types. Also adds TODO comments for some bugs I
found while reading the _matchSubtype code.
Change-Id: I7b3318e3cc1f89c09960efe82d3cfdbf48ab9746
Reviewed-on: https://dart-review.googlesource.com/49962
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
... and remove typeContinuation from top level parsing,
class member parsing, and ModifierRecoveryContext2
Change-Id: I2a9653e42c180a050316205fdf320c61c30ae47c
Reviewed-on: https://dart-review.googlesource.com/49562
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
Before, the part-URI was serialized as a file-URI and conflated with
source location information. The part-URI is the URI in the following
declaration in a Dart source file:
part "URI";
This is different from what we normally call a file-URI. A file URI
is used to point to the source location of the part declaration, not
the URI in the part declaration.
Furthermore, the field was serialized using writeUriReference which
only works for URIs that are in the uriToSource map on a Component.
Although this might seem like a safe optimization, it doesn't work
if the uriToSource map is omitted or if a part declaration refers to
a missing file.
Finally, due to the confusing use of fileUri, LibraryPart was
mistakenly implementing FileUriNode and annotations were stripped
of source locations if the source for the part were omitted from
uriToSource.
The partUri field is now an unresolved string that can be resolved
against either the parent library's import- or file-URI to obtain
either version as needed.
Change-Id: I255cb4eeaf89928292ab32a2f6be9ead6cc8cee1
Reviewed-on: https://dart-review.googlesource.com/49500
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
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>
* 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>
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>
I realize that it is convenient to get debug output while working on
a test, but it is probably better to enable this debug output only
while one is working in this area, not for everyone ;-)
R=brianwilkerson@google.com, danrubel@google.com
Change-Id: I4027b3351eba07ba2b5e13471bbdb076ee72d388
Reviewed-on: https://dart-review.googlesource.com/48764
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>