Commit graph

13323 commits

Author SHA1 Message Date
Konstantin Shcheglov edd17a8638 Merge AST interfaces into implementation library, re-export.
Bug: https://github.com/dart-lang/language/issues/3135
Change-Id: Icbc2a4e506e9e58c830b53f7aecce92189bb2d1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308402
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-10 16:57:59 +00:00
Konstantin Shcheglov db143df804 Increment AnalysisDriver.DATA_VERSION
This should have been done in
https://dart-review.googlesource.com/c/sdk/+/267340

Change-Id: Ie1e6ea56bbfdd807c2e7097c6c06b898693b2850
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-09 18:05:15 +00:00
Konstantin Shcheglov 028ca9d02f Remove null assert in _contextFor()
Change-Id: Iea684f57eb356b676a620bb08e82a28d1df99022
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307971
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-08 19:52:30 +00:00
Ludi Zhan 4079a47cc4 [analyzer] Introduce a new annotation @visibleOutsideTemplate
The new annotation is intended to be used on members of class, enum or mixin to opt out the @visibleForTemplate visibility restriction cascaded from class- / enum- / mixin- level.

1. Throw warning if the annotation is added to a invalid target.
2. Update @visibleForTemplate diagnostics logic to opt out members annotated with @visibleOutsideTemplate.

Change-Id: Iec546fc7785cd45f39a1b2a2cc8849ef1cf9d04a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304825
Reviewed-by: Marya Belanger <mbelanger@google.com>
Auto-Submit: Ludi Zhan <ludizhan@google.com>
Commit-Queue: Ludi Zhan <ludizhan@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-08 18:47:15 +00:00
Konstantin Shcheglov f569174ea0 Stop using elementMatcher() method, use textual expectaitons.
Change-Id: I11946d135a4e82e8fcdd382d3c4cc50e6ab1666f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308163
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-08 18:27:14 +00:00
Konstantin Shcheglov 4ff67a7ccb Remove assertMember(), use textual expectations.
Change-Id: I009a17ba1ffecd7614577b73f191a954cb9d3680
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307976
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-08 15:59:07 +00:00
Kallen Tu 3542e86611 [analyzer] Fix CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST not reporting.
Found a bug related to https://dart-review.googlesource.com/c/sdk/+/307182 which
surfaced the fact that we don't handle InvalidConstants in ConstantVerifier._validateFieldInitializers.

Change-Id: If270faa4718f67a930f8ec5ea32f1dd1d8a7e97c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307966
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-06-07 21:30:34 +00:00
Konstantin Shcheglov 692ef6be03 Add quotedAndCommaSeparatedWithOr and use for TransformSetParser.
Change-Id: Ie599d1e7b24efa137cb342392d278df051fbed33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307666
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-07 17:19:59 +00:00
Konstantin Shcheglov 8e37b41c05 Issue 52624. Report type parameters in NamedType(s) inside constant patterns.
Bug: https://github.com/dart-lang/sdk/issues/52624
Change-Id: Ic779641025fdf9d80b67457a26c704c5481e57ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307663
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-07 17:13:58 +00:00
Konstantin Shcheglov 5cb4093613 Issue 52432. Create DefaultSuperFormalParameterElementImpl for invalid code.
Bug: https://github.com/dart-lang/sdk/issues/52432
Change-Id: I03a1320dce1a56448046bf625ae751cdb8f931af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307670
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-07 01:32:58 +00:00
Kallen Tu bc94e7662b [analyzer] Refactor visitConditionExpression in the const evaluator.
Moved a test from `constant_test.dart` to slowly migrate it over.

Change-Id: Id7d0ef0edcfa4fced056ec8fc937b060a74f4468
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306919
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-06-06 19:30:19 +00:00
Konstantin Shcheglov 526ce3aba4 Issue 52005. Convert non-exhaustive returning SwitchStatement to SwitchExpression when followed by throw.
Bug: https://github.com/dart-lang/sdk/issues/52005
Change-Id: I16bf21703e4404e805dbc40906be5936e95f102c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307510
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-05 22:44:53 +00:00
Kallen Tu f92c6da7bf [analyzer] Refactor visitAsExpression and visitIsExpression in the constant evaluator.
Changed the signature of `_getConstant` as a smaller change.

Change-Id: Iac258558a32f11030db53edd658371bacbcc5ee6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307182
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-06-05 20:10:15 +00:00
Konstantin Shcheglov 88f05965ac Issue 52606. Fix AstNodeExtension.nodeCovering() when selection if at the end of Comment.
Bug: https://github.com/dart-lang/sdk/issues/52606
Change-Id: I1cfe427979e82e837d34e5fa45a310474b0a2aa8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307504
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-05 18:39:27 +00:00
Keerti Parthasarathy 56cb8de973 Make ParsedUnitResult and ParsedLibraryResult superclasses of ResolvedUnitResult and ResolvedLibraryResult respectively.
Change-Id: I00a8c07b8487c27c22997523803028fd01b4293a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306909
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-06-05 16:43:24 +00:00
Paul Berry 39de3f2e5b Field promotion: track field accesses via SSA node.
If a user promotes a field and then subsequently changes the variable
used to access it, the promotion must be discarded. For example, in
this code:

    class C {
      int? _i;
    }
    test(C c1, C c2) {
      C c = c1;           // (1)
      if (c._i != null) { // (2)
        print(c._i + 1);  // (3)
        c = c2;           // (4)
        print(c._i + 1);  // (5)
      }
    }

The test at (2) promotes `c._i` to non-null, so (3) is ok. But since
`c` is reassigned at (4), (5) should be a compile-time error.

Previously, flow analysis used one promotion key to track `c` and one
promotion key to track `c._i`. The `PromotionKeyStore` associated each
promotion key with a map containing the promotion keys of all of its
properties. So, for example, if the promotion key for `c` was 10 and
the promotion key for `c._i` was 11, the `PromotionKeyStore` would
associate promotion key 10 with the map `{'_i': 11}`, so that each
time `c._i` was accessed, promotion key 11 would be found. In order to
detect the compile-time error at (5), it had to keep track of the fact
that keys 10 and 11 were related, so that the assignment to `c` at (4)
could invalidate the promotion of `c._i`. It accomplished this by
linking together all the related promotion keys in a circularly linked
list, which it would walk at the time of any variable assignment.

This worked, but it required a lot of complex bookkeeping. Also, it
posed problems for integrating field promotion with cascades, for
example, in the following code:

    class B {
      void f([_]) { ... }
    }
    class C {
      B? _b;
    }
    test(C c1, C c2) {
      C c = c1;           // (6)
      if (c._b != null) { // (7)
        c.._b.f(          // (8)
	    [
              c = c2,     // (9)
	      c._b.f(),   // (10)
	    ])
         .._b.f();        // (11)
      }
    }

The cascaded access `.._b.f` at (8) should be ok, since `c._b` has
been promoted. But since there is an assignment to `c` at (9), the
promotion should not carry over to (10), and an error should be
reported. However, no error should be reported at (11) because the
cascaded access to `.._b.f` at that location is using the old value of
`c` that was captured at the beginning of the cascade, prior to the
assignment. There's no way to achieve this by invalidation alone,
since the code locations at which the promotion is valid ((8) and
(11), but not (10)) aren't even contiguous.

The solution to the problem is to store property promotion keys in
`SsaNode`s used by flow analysis, rather than in the
`PromotionKeyStore`. Since a fresh `SsaNode` is allocated each time a
variable is assigned, this automatically invalidates any previous
property promotions without the need for any extra bookkeeping. So, in
the first example, at (1), an `SsaNode` is allocated and associated
with the promotion key for `c`. At (2), a promotion key is created for
`c._i` and stored in `c`'s `SsaNode`, and the flow model is updated to
indicate that that key has been promoted to non-null. At (3), that
promotion key is reacalled from the `c`'s `SsaNode`, so the promotion
is still in effect. At (4), a fresh `SsaNode` is associated with
`c`. Since that `SsaNode` doesn't contain any promotion keys yet, at
(5), the access to `c._i` causes a fresh promotion key to be
allocated, with no associated promotions. So the invalidation happens
automatically due to the fact that a new `SsaNode` was created.

Flow analysis doesn't yet support cascades, but here's how the second
example is intended to work: as before, at (6), an `SsaNode` is
allocated and associated with the promotion key for `c`. At (7), a
promotion key is created for `c._b` and stored in `c`'s `SsaNode`, and
the flow model is updated to indicate that `c._b` has been promoted to
non-null. At (8), the `SsaNode` for `c` is captured and saved for
later use. At (9), a fresh `SsaNode` is created and associated with
`c`. That fresh `SsaNode` is consulted at (10), so `c._b` is not
promoted at this point. However, at (11), the previously stored
`SsaNode` is used, so the promotion of `._b` still works.

Change-Id: I64519fbcb2368a37aa18adf35cee0ffd290db9b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307140
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-06-04 19:41:54 +00:00
Paul Berry f180b7037c Shared analysis: remove bogus support for late variable patterns.
When I was first developing the shared analysis logic for patterns, I
imagined that ordinary variable declaration statements would
eventually be re-interpreted as pattern variable declarations, where
the pattern was simply a variable pattern. In order to facilitate
this, I added support for late variable patterns, so that a
decalration of a late variable could be interpreted as a pattern
variable declaration where the pattern was a "late variable pattern".

In the final implementation, however, this functionality never got
used, except in flow analysis unit tests. Both the analyzer and the
CFE continue to use their old logic for analyzing ordinary variable
declarations (including late variable declarations), and only invoke
the shared logic when the declaration in question is truly a pattern
variable declaration.

In retrospect I believe this is the right approach; ordinary
(non-patterned) variable declarations are common enough that it makes
sense to have separate logic for analyzing theem; invoking the full
generality of pattern variable declarations would simply waste CPU
cycles.

So this CL removes support for late variable patterns from the shared
implementation; this will make future refactoring of flow analysis
logic easier.

Since the flow analysis unit tests *were* taking advantage of the
shared logic for late variable patterns, I had to add some separate
logic to the tests to replicate the old functionality when analyzing
an ordinary late variable declaration. This new logic is only used in
tests.

Change-Id: If51efab3c63bdc20d1f2772c2d2dd1e3f487bb00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307183
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-06-04 19:40:37 +00:00
Kallen Tu 4f2f3405fb [analyzer] Refactor visitInterpolationExpression in constant evaluator.
Added `_getConstant` to handle the unfortunate `null`s returned by the ConstantVisitor. Refactored other code with this new helper too.

Change-Id: Ic2ce009b78fee151a1a6fa5b2d2621646cbf2c3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306672
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-02 19:55:02 +00:00
Parker Lougheed 25c0ae1c42 Link to dart.dev for linter rules
This allows more flexibility as we can configure the redirect overtime, compared to the GitHub hosted site which we have less control over. It could even redirect to the old linter site in the meantime if desired.

Contributes to https://github.com/dart-lang/linter/issues/4411 and https://github.com/dart-lang/site-www/issues/4498

Change-Id: I3512002cdf7f62c0338d67cec0d7091f1166479d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307000
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-02 18:26:13 +00:00
Jake Macdonald 310baf2737 mark all public interfaces as abstract interface classes
make Code a sealed type, and all subtypes base classes

Change-Id: I328b6a25446dc89e88ae2f1c7e137b969f1b86ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306682
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-06-01 19:30:41 +00:00
Kallen Tu 0d1a9df087 [analyzer] Refactor visitAdjacentStrings and visitStringInterpolation for the constant evaluator.
In doing so, made Constant sealed to use in switches.

We want to avoid passing back null as much as possible, so replacing those with InvalidConstant errors.

Change-Id: I5271c15961679316f7cbee9159150e3c7350926f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306671
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-06-01 16:30:18 +00:00
Paul Berry 709c0e4ccd Flow analysis: combine ExpressionInfo, ReferenceWithType, and EqualityInfo.
Previously, flow analysis used three classes to keep track of
information about expressions that have been visited:

- ExpressionInfo, to keep track of information about expressions whose
  truth or falsity has an effect on flow analysis (such as `== null`
  checks, `is` checks, and combinations thereof those using `&&` and
  `||`), as well as identifying the literal expression `Null`.

- ReferenceWithType, to keep track of information about expressions
  that represent something that can be promoted (references to
  variables and fields), as well as the static type of the expression.

- EqualityInfo, which wrapped ExpressionInfo and ReferenceWithType,
  and also redundantly stored the static type of the expression.

These have now been combined into a single class hierarchy with a base
class called `ExpressionInfo`. This makes the code easier to reason
about, because it is no longer necessary to think about which of the
three above classes is needed in a given situation. Also, it helps
prepare for a follow-up CL in which I plan to refactor how flow
analysis gathers this information; the refactor will be easier with
just a single class hierarchy of information to be gathered.

This required a modest expansion of the API to flow analysis to
include more static types, since previously, static types weren't
needed by the ExpressionInfo class.

Change-Id: Id3de8b19049f8d920ebe85ab58c624ae3e55f226
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304211
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-06-01 15:53:18 +00:00
Konstantin Shcheglov 6879f9586c Issue 52535. Mark imported extensions used in pattern fields as used.
Bug: https://github.com/dart-lang/sdk/issues/52535
Change-Id: If851ad42fad5741dccc3856a55ee0454e949beeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306669
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-31 20:04:25 +00:00
Konstantin Shcheglov e64a6dc87c Issue 52453. Collect constant dependencies for relational patterns.
Bug: https://github.com/dart-lang/sdk/issues/52453
Change-Id: Id0f59659ac7b6b67e4caad97f7c97c3ca1c55ea6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306681
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-31 19:58:22 +00:00
Konstantin Shcheglov 5db76194e9 Cache the whole library result when compute a unit result.
Bug: https://github.com/dart-lang/sdk/issues/47968
Change-Id: I2b20a3931f0374a20151c14c0e99fd5b971553ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306660
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-31 19:29:38 +00:00
Jens Johansen bda10d7987 [analyzer] Cache FeatureSets
This CL caches `FeatureSet`s (really `ExperimentStatus`s) in the
FeatureSetProvider.

When analyzing rwf-materials (562 contexts) with a filled cache I get
these numbers:

Before:
509,901 instances of `ExperimentStatus`.
Current memory: 3.21GB.
Peak memory: 3.24GB.
Heap: 2.61GB of 2.68GB.

After:
2,246 instances of `ExperimentStatus`.
Current memory: 2.80GB
Peak memory: 2.85GB
Heap: 2.21GB of 2.28GB

Difference:
Instances: -99.55%.
Current memory: -12.77%.
Peak memory: -12.03%.
Heap: -15.32% (used); -14.92% (size).
Change-Id: I3901310eed70733f8bd06ad81bf940b848734723
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306460
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-05-31 06:22:19 +00:00
Konstantin Shcheglov b9302286cd Issue 52548. When checking constant pattern matching, union 'T?' bound with Null.
Bug: https://github.com/dart-lang/sdk/issues/52548
Change-Id: I103134c48ea30df95f8e710518b92360b6f13d98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306309
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-30 20:30:14 +00:00
Konstantin Shcheglov b0bd3926a8 Issue 52538. Don't report RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA when no parenthesis.
Bug: https://github.com/dart-lang/sdk/issues/52538
Change-Id: I1f49090c72d51993ec811cfcd93b8a19199dc96f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306306
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-30 19:59:27 +00:00
Kallen Tu 4fa021ced5 [analyzer] Change return type of ConstantVisitor (initial)
Changes the return type of ConstantVisitor and make sure everything works
by unwrapping Constants. Added a bunch of TODOs to slowly go through
in follow up CLs.

Change-Id: I5dbb3f4eb6c72daa1fb649b746c8fdc4fb83dadb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305847
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-05-30 18:18:22 +00:00
Konstantin Shcheglov c8c99b5f94 Cache getResolvedLibrary() results for priority libraries.
Bug: https://github.com/dart-lang/sdk/issues/47968
Change-Id: I123e8cea6ed629dd3fc1379e7e3a86ae5685d65e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306302
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-30 17:25:29 +00:00
Paul Berry 76f803a41c Additional test cases in support of record/variable pattern disambiguation.
Two of these tests (`recordPattern_nullable_beforeAs` and
`recordPattern_nullable_beforeWhen`) verify that the fix for #52439
(Destructuring with explicit type of nullable record is a parsing
error), which causes `(...)? identifier` to be recognized as a
variable pattern, doesn't get confused by the pseudo-identifiers `as`
and `when`, and so it continues to correctly parse `(...)? as ...` as a
cast pattern and `(...)? when ...` as a guarded pattern.

The other two tests (`recordPattern_nonNullable_beforeAs` and
`recordPattern_nonNullable_beforeWhen`) verify that `(...) as ...` and
`(...) when ...` are parsed correctly. These forms were never broken,
but they were not well tested either.

Bug: https://github.com/dart-lang/sdk/issues/52439
Change-Id: I866e1c7a6a8e47e0cd91a1a77654405f395b50da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305844
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-05-30 12:48:26 +00:00
Daco Harkes e1ae1b48ae [vm/ffi] dartdev CLI native-assets
This CL introduces native assets suport for `dart run` and introduces
`dart build` which is similar to `dart compile` but outputs a folder
instead to that native assets can be bundled with an executable.

Change-Id: Ib6cfb95539f0adee46c99e531e440928c3f72f2b
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267340
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-05-30 09:10:28 +00:00
Konstantin Shcheglov fbdcfdf2ae Use WithLanguage219Mixin, and language 2.19 instead of 2.18
It is 2.19 that is different from 3.0, and has different features.

Change-Id: I869ac0de76502f0d2b606e0782fee83f66e86283
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306127
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-26 20:32:48 +00:00
Konstantin Shcheglov 3091cefa1f Issue 52514. Fix for UNUSED_IMPORT when extension declares '[]='.
Bug: https://github.com/dart-lang/sdk/issues/52514
Change-Id: I88fcf39440fbb9969d901c5a293d9a1b11aff30b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306123
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-26 19:14:37 +00:00
Konstantin Shcheglov fc399d16b3 Issue 52528. Report an error for 'const' instance creation with not a constructor of enum.
Bug: https://github.com/dart-lang/sdk/issues/52528
Change-Id: I8123e4c8d6bb2e62278b14c8e8b0cb1ef542ff15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-26 18:24:08 +00:00
Konstantin Shcheglov 2077a811f7 Issue 51323. Don't parse RecordLiteral(s) before language 3.0
Bug: https://github.com/dart-lang/sdk/issues/51323
Change-Id: Icd896b0beec5b43775d9d9e04364f086da23cdb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305142
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-26 18:22:34 +00:00
Paul Berry e213846ba0 Patterns parsing: fix record-typed variable patterns before certain tokens.
Previously, if a record-typed variable pattern lacked a `var` or
`final` keyword, and was followed by one of the tokens `||`, `&&`,
`as`, `?`, `!`, `when`, or `=>`, the parser would fail to recognize
it. This happened because the call to `computeVariablePatternType`
wasn't passing `true` for the optional parameter `required`; that in
turn placed `computeType` in a mode where it believed it was parsing a
potentially ambiguous construct in a top-level declaration, and hence
it would only accept the record type if the variable name was followed
by something that looked like part of a correct declaration (e.g. a
comma).

The fix is to pass `true` for the optional parameter `required` of
`computeVariablePatternType`. This places `computeType` in a mode
where it accepts the record type regardless of what follows it. This
is correct behavior since at the point where a variable pattern is
being parsed, ambiguities have already been taken care of and the
construct being parsed is most definitely a variable pattern.

Fixes #52521.

Change-Id: If20772ad914827a29df45c27eefb382ec1f470d2
Bug: https://github.com/dart-lang/sdk/issues/52521
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305848
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-05-26 13:51:31 +00:00
Jens Johansen 54a59072a1 [analyzer] Improve AbstractDartSdk._getPath more
This is the follow-up to
https://dart-review.googlesource.com/c/sdk/+/282280 that I had
forgotten about.

When analyzing rwf-materials (562 contexts) with a filled cache I get
these numbers:

Before this CL (i.e. parent CL):
99671 ms
98499 ms
99678 ms

With this CL:
85764 ms
86204 ms
86548 ms

Difference at 95.0% confidence
        -13110.7 +/- 1256.93
        -13.2054% +/- 1.26601%
        (Student's t, pooled s = 554.547)

Change-Id: Idcde0c9b92eb34467ce69ee7d552f4a8d035286f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305681
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-26 06:35:01 +00:00
Jens Johansen a3df9a1ed1 [analyzer] Don't do string concat in String.startsWith
When analyzing rwf-materials (562 contexts) with a filled cache I get
these numbers:

Before this CL (i.e. parent CL):
102829 ms
100934 ms
100991 ms

With this CL:
99671 ms
98499 ms
99678 ms

Difference at 95.0% confidence
        -2302 +/- 2041.63
        -2.26609% +/- 2.00979%
        (Student's t, pooled s = 900.749)

Change-Id: I30025b15f7b8c637d83b2cef234c0e7a602535f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305680
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-26 06:27:47 +00:00
Jens Johansen b5224c5f72 [analyzer] ContextRootImpl.isAnalyzed already have the resource, don't get it again
When analyzing rwf-materials (562 contexts) with a filled cache this
CL removes something like ~1.6 million calls to "isDirectorySync" which -
I think - reads from the filesystem.

On Linux I get this change (on Windows I'm guessing the change is bigger
as the filesystem is often slower):

Before the fix:
111662 ms
112053 ms
112176 ms

With this fix:
102829 ms
100934 ms
100991 ms

Difference at 95.0% confidence
        -10379 +/- 1780.48
        -9.26997% +/- 1.59023%
        (Student's t, pooled s = 785.532)

I.e. it makes it ~10 seconds or ~9% faster.

Change-Id: I42f54b2ff7510365c5a683c993b6b759b35bd152
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305661
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-26 06:26:58 +00:00
Konstantin Shcheglov 7d138719ec Use OwnedFiles to track which files are owned by which driver.
So, we don't have to recompute it at every symbol search.
For Flutter repository, searching for 'ButtonStyle' is 40% faster.

SHA: 47fe150674
Description: before
  [mean: 56.4][stdDev: 1.471][min: 54.0][max: 61.0]

Description: own files
  [mean: 35.0][stdDev: 1.308][min: 33.0][max: 38.0]
Change-Id: Id497bf4117bdfafeeccd04601fd0198e22624c0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305843
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-26 00:42:12 +00:00
Kallen Tu d48f955121 [analyzer] Add Constant and InvalidConstant to the const evaluator.
Adds an abstract type Constant with two subtypes: DartObjectImpl and
InvalidConstant.
Initial set up for changing the return type in the constant evaluator.

Change-Id: Ia713dee6453937f87d1ae72d3bd240e67d6c13eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-25 17:15:57 +00:00
Paul Berry 54372b3308 Flow analysis: simplify API for accessing field properties.
Instead of having separate API methods `propertyGet` (for accessing
the properties of an explicit target) and `thisOrSuperPropertyGet`
(for accessing the properties of `this` or `super`), switch to a
single `propertyGet` method. Make the `target` parameter of
`propertyGet` a sealed class (`PropertyTarget`) with three subtypes
representing the three possible kinds of targets:
- `ExpressionPropertyTarget` for an explicit target expression,
- `SuperPropertyTarget` is the target is `super`, and
- `ThisPropertyTarget` if the target is `this`.

Also adjust the API for `promotedPropertyType` to use the new
`PropertyTarget` class for its `target` parameter, rather than a
nullable `target` expression and boolean `isSuperAccess` parameter.

Change-Id: I90535f6d6741776548bc4d60359fd4c40c0fab90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304763
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-05-24 17:50:57 +00:00
Konstantin Shcheglov 305fa3d77c Use names mask to filter libraries when search for symbols.
Before.
SHA: 7501d10e51
Description: check if the library is ready in getLibraryByUri()
  [mean: 43.2][stdDev: 1.350][min: 41.0][max: 47.0]

After.
Description: pre-filter whole libraries using name masks
  [mean: 37.2][stdDev: 1.362][min: 35.0][max: 41.0]

Change-Id: I041ba68c48e3afa8ac528477aa470cbaa770b4cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304830
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-24 17:14:47 +00:00
Konstantin Shcheglov 645587bc70 Issue 52486. Fix LinterContext.resolveNameInScope() in SwitchExpression cases.
Bug: https://github.com/dart-lang/sdk/issues/52486
Change-Id: I7d00ed03f8da37e7adb2959a62acefbd1904770a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305060
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-23 19:19:38 +00:00
Sam Rawlins 6c5836e424 Fix typo in MockSdk
Change-Id: I22373c7f1fe5106423aab3b89d60e54d54550e3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304761
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-22 23:45:34 +00:00
Konstantin Shcheglov d856c6a460 Move FuzzyMatcher to analyzer.
In a future CL I'd like to filter out whole libraries depending
on whether they could have a match. At this point the search, filtering,
and matching become entangled too much to bind them with outside
code in the server. Instead, it all will be the analyzer's concern.

Change-Id: Iefdadbf92046218b3a2607fbeadd37494522112e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304841
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-22 23:10:07 +00:00
pq 9998ad2561 Update hint code doc
Change-Id: I79de29c4b12a04a1419c75678904023392cf44e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304822
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-05-22 21:40:20 +00:00
Konstantin Shcheglov d85aa126e3 Require SDK 3.0.0 for analyzer/.
Change-Id: I9e787930d2101b39808c44d2e7bd537337ac3855
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304286
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-22 20:51:40 +00:00
pq c6720775bb Report replacedBy info for deprecated lints
Fixes https://github.com/dart-lang/sdk/issues/52472


Bug: https://github.com/dart-lang/sdk/issues/52472
Change-Id: I4278a735774cca731d0a3d96cd483eeefc884baf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304800
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-22 20:20:20 +00:00
Konstantin Shcheglov efe0ca193f Prepare to publish analyzer 5.13.0 and _fe_analyzer_shared 61.0.0
Change-Id: Ic1402c8a003573a0861c9a907c0a14e9b95f4859
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304561
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-19 21:11:29 +00:00
Konstantin Shcheglov 7501d10e51 Check if the element is already computed in getLibraryByUri().
This makes symbol search 2 times faster.

Before:
(name: request, count: 1, elapsed: 0:00:00.138251, elapsedSelf: 0:00:00.000463)
  (name: findDeclarations, count: 1, elapsed: 0:00:00.137743, elapsedSelf: 0:00:00.002565)
    (name: discoverAvailableFiles, count: 1, elapsed: 0:00:00.000114, elapsedSelf: 0:00:00.000114)
    (name: ownKnown, count: 1, elapsed: 0:00:00.005737, elapsedSelf: 0:00:00.005737)
    (name: findDeclarations, count: 1, elapsed: 0:00:00.129327, elapsedSelf: 0:00:00.007679)
      (name: getLibraryByUri, count: 7091, elapsed: 0:00:00.082191, elapsedSelf: 0:00:00.082191)
      (name: finder, count: 7091, elapsed: 0:00:00.039457, elapsedSelf: 0:00:00.039457)
  (name: convert, count: 1, elapsed: 0:00:00.000045, elapsedSelf: 0:00:00.000045)(declarations: 5)


After:
(name: request, count: 1, elapsed: 0:00:00.070215, elapsedSelf: 0:00:00.000583)
  (name: findDeclarations, count: 1, elapsed: 0:00:00.069580, elapsedSelf: 0:00:00.002453)
    (name: discoverAvailableFiles, count: 1, elapsed: 0:00:00.000126, elapsedSelf: 0:00:00.000126)
    (name: ownKnown, count: 1, elapsed: 0:00:00.004227, elapsedSelf: 0:00:00.004227)
    (name: findDeclarations, count: 1, elapsed: 0:00:00.062774, elapsedSelf: 0:00:00.011947)
      (name: getLibraryByUri, count: 7091, elapsed: 0:00:00.009449, elapsedSelf: 0:00:00.009449)
      (name: finder, count: 7091, elapsed: 0:00:00.041378, elapsedSelf: 0:00:00.041378)
  (name: convert, count: 1, elapsed: 0:00:00.000052, elapsedSelf: 0:00:00.000052)(declarations: 5)

Bug: https://github.com/Dart-Code/Dart-Code/issues/4106
Change-Id: Iade1c80870a0bbd6b909a5306be57499bed27b27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304540
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-19 19:55:28 +00:00
Paul Berry 70e7adff19 Field promotion: distinguish between this. and super. accesses.
When promoting fields, in order to avoid unsoundness, we need to
distinguish between field accesses performed through `super` and field
accesses performed through `this`. Otherwise, a user could do
something like this:

    class B {
      final int? _i;
      B(this.i);
    }
    class C extends B {
      final int? _i;
      C(this._i, int? superI) : super(superI);
      int f() {
        if (super._i != null) {
          return this._i; // UNSOUND: `this._i` could be `null`
        }
      }
    }

To avoid this problem, flow analysis now uses separate promotion keys
for `super` and `this`, so that promoting a variable through `this`
leaves it unpromoted when accessed via `super`, and vice versa.

Note that in principle the implementations could inspect the enclosing
class, and only distinguish `this.` and `super.` accesses in the case
where it contains a declaration matching the field name. But doing so
would carry a performance and implementation complexity cost, and
would confer very little real-world benefit (since in practice users
don't mix `this.` and `super.` accesses and expect them to refer to
the same field).

Fixes #50138.

Bug: https://github.com/dart-lang/sdk/issues/50138
Change-Id: Ia0fd79b5ed7649d23a28efcbffb59b4c9ad63f70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304364
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-05-19 18:29:49 +00:00
Kallen Tu 345d0f3a47 [analyzer] Issue 37238: Multiple errors for type mismatch assignments.
Avoid reporting an error if the static types are mismatched because
CompileTimeErrorCode.INVALID_ASSIGNMENT would have already been
reported by the ErrorVerifier.

Closes #37238

Bug: https://github.com/dart-lang/sdk/issues/37238
Change-Id: I2248d054ed6bf6a546e998afb9b731a36e197780
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304362
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-05-19 16:27:58 +00:00
Konstantin Shcheglov c9557fe568 Reduce instrumentation for WorkspaceSymbolHandler.
I played with it some more, and found that the overhead of measuring
too fine grainly, when we have tens and hundreds thousands of relatively
inexpensive operations, is too high.

Change-Id: I4038e3972efff860d568c02008120092f99b8298
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304368
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-19 14:38:38 +00:00
Konstantin Shcheglov e1f153f7a2 Add tests for AwaitExpression and unresolved identifiers.
I saw that the linter roll reported a strange InvalidType related
error. So, I wanted to check if this is something I can reproduce.
I cannot, but the tests might be useful anyway.

Change-Id: I21138685c4fee028f0620d3fcfa3a221a304c951
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304325
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-19 01:12:08 +00:00
Danny Tuppeny 34a21f5691 [analysis_server] Switch to using FuzzyMatcher instead of RegExp for LSP workspace symbols
See https://github.com/Dart-Code/Dart-Code/issues/4106#issuecomment-1552948926.

In my tests on the Flutter repo, this reduces the matching from around 200ms to around 40ms.

Before:
(name: request, count: 1, elapsed: 0:00:00.708230, elapsedSelf: 0:00:00.000487)
  (name: findDeclarations, count: 1, elapsed: 0:00:00.707656, elapsedSelf: 0:00:00.002735)
    (name: discoverAvailableFiles, count: 1, elapsed: 0:00:00.000187, elapsedSelf: 0:00:00.000187)
    (name: ownKnown, count: 1, elapsed: 0:00:00.023311, elapsedSelf: 0:00:00.023311)
    (name: findDeclarations, count: 1, elapsed: 0:00:00.681423, elapsedSelf: 0:00:00.016362)
      (name: getLibraryByUri, count: 7276, elapsed: 0:00:00.295596, elapsedSelf: 0:00:00.295596)
      (name: finder, count: 7272, elapsed: 0:00:00.369465, elapsedSelf: 0:00:00.055566)
        (name: addDeclaration, count: 317711, elapsed: 0:00:00.313899, elapsedSelf: 0:00:00.080608)
          (name: doNothing, count: 317711, elapsed: 0:00:00.020405, elapsedSelf: 0:00:00.020405)
          (name: regExp, count: 317711, elapsed: 0:00:00.212886, elapsedSelf: 0:00:00.212886)
  (name: convert, count: 1, elapsed: 0:00:00.000087, elapsedSelf: 0:00:00.000087)(declarations: 1)


After:
(name: request, count: 1, elapsed: 0:00:00.522033, elapsedSelf: 0:00:00.003331)
  (name: findDeclarations, count: 1, elapsed: 0:00:00.518648, elapsedSelf: 0:00:00.002939)
    (name: discoverAvailableFiles, count: 1, elapsed: 0:00:00.000213, elapsedSelf: 0:00:00.000213)
    (name: ownKnown, count: 1, elapsed: 0:00:00.021037, elapsedSelf: 0:00:00.021037)
    (name: findDeclarations, count: 1, elapsed: 0:00:00.494459, elapsedSelf: 0:00:00.016197)
      (name: getLibraryByUri, count: 7276, elapsed: 0:00:00.292021, elapsedSelf: 0:00:00.292021)
      (name: finder, count: 7272, elapsed: 0:00:00.186241, elapsedSelf: 0:00:00.050400)
        (name: addDeclaration, count: 317711, elapsed: 0:00:00.135841, elapsedSelf: 0:00:00.072235)
          (name: doNothing, count: 317711, elapsed: 0:00:00.019244, elapsedSelf: 0:00:00.019244)
          (name: isMatch, count: 317711, elapsed: 0:00:00.044362, elapsedSelf: 0:00:00.044362)
  (name: convert, count: 1, elapsed: 0:00:00.000054, elapsedSelf: 0:00:00.000054)(declarations: 1)
Change-Id: Ib8775536fb7b16b9d29c2839167ce41de9ecc874
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304341
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-18 18:31:28 +00:00
Konstantin Shcheglov c207dafe77 Instrument WorkspaceSymbolHandler.
Change-Id: Ia822b253124b53e5ee283f7b3cce15db050eedb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-18 15:43:17 +00:00
Konstantin Shcheglov 2223d8b324 Issue 52388. Report 'await super', without selector.
Bug: https://github.com/dart-lang/sdk/issues/52388
Change-Id: I19fe6d3e638e75ff36739949b9ea9e24cb043b73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304220
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-18 15:39:26 +00:00
Konstantin Shcheglov 64fcb8de1b Prepare for removing deprecated methods from NamedType.
The actual removal will happen in (to be rebased on top of this):
https://dart-review.googlesource.com/c/sdk/+/303280

Fixing direct uses of the deprecated `Identifier get name` is apparently
only about a half of the work. I should have followed my own advice to
the clients and prepared better.

These changes are necessary because we will stop creating and
visiting `Identifier`, and so `NamedType` should be handled directly.

Change-Id: Ie07b75b15eab277ed6c9b29a838561a7eb71f588
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303425
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-18 01:54:21 +00:00
Parker Lougheed deddb64ff7 [pkg/analyzer] Fix meta annotation links in diagnostic messages
Bug: https://github.com/dart-lang/site-www/issues/4901
Change-Id: I238d9508984846c4bbe2bb1b23eb2b12fd262ed8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-18 00:55:53 +00:00
Konstantin Shcheglov 92faa11311 When resolve a priority library, cache all ResolvedUnitResultImpl(s).
...not just the result for the immediately requested file.

Change-Id: I85f74708fb32ff79b3c8a8b68c9cea5db8093000
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-17 20:46:38 +00:00
Konstantin Shcheglov b54783f2f3 Issue 52425. Ignore SwitchCase when it (erroneously) happens in 3.0 library.
Bug: https://github.com/dart-lang/sdk/issues/52425
Change-Id: Ifa621eb10af698664cb9461cb3db8839eb73d3e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304141
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-05-17 18:15:48 +00:00
Konstantin Shcheglov bd0e77c4fc Issue 52409. Reading a Never typed getter makes the flow unreachable.
Bug: https://github.com/dart-lang/sdk/issues/52409
Change-Id: I675ed8f8cfa0d2e5327c2c6bc0fb1bda7bde038c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303840
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-17 03:28:07 +00:00
Konstantin Shcheglov 2ed244a575 Issue 52385. Use actual record value type, not the static one.
Bug: https://github.com/dart-lang/sdk/issues/52385
Change-Id: Ieb04e32e50a6ff3c3dc839676c7e3224f228971a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303445
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-16 18:55:38 +00:00
Konstantin Shcheglov 39f240e751 Reset _classMembersLengthsIndex in LibraryReader.
This change might help with analyzing the bug.

Bug: https://github.com/dart-lang/sdk/issues/51855
Change-Id: I214a6238e696ffa2ba16df11946e65da18e81945
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303782
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-16 17:47:48 +00:00
Konstantin Shcheglov 85d09eb89f Issue 52387. Report an error for !super
Bug: https://github.com/dart-lang/sdk/issues/52387
Change-Id: I9893315b988c3096ea2d103f6a46f00ff0450afe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303446
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-16 15:51:45 +00:00
Konstantin Shcheglov 18de295d52 Issue 53378. Report when 'super' is used as a standalone expression, not as a receiver of an invocation.
Bug: https://github.com/dart-lang/sdk/issues/52378
Change-Id: I4dea36b545a4c26ed8e8dc54367159b48fae2bfe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303501
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-16 00:22:57 +00:00
Konstantin Shcheglov f6c4ba3748 Don't report exhaustiveness diagnostics when InvalidType is present.
This partially reverts changes made in
https://dart-review.googlesource.com/c/sdk/+/302455

Bug: https://github.com/dart-lang/sdk/issues/52151
Change-Id: I1851e170794f4777499d81fea4fb0f5c877a0bbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303084
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-15 21:54:50 +00:00
Brian Wilkerson 7f1a5cc20f Attempt to fix the windows bot
This reverts the changes to ResourceProviderMixin that made it possible
for a test to explicitly set the context type of the resource provider.
I don't believe that's necessary because we run all of the tests on the
windows bot with that context type anyway.

It also removed the windows-specific subclasses of the URI suggestion
tests. They were duplicates of the non-windows-specific tests that were
probably added before we had a windows bot.

Change-Id: I4547cc768992c4d272871032a6939cd216dc5e96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303422
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-15 20:30:25 +00:00
Konstantin Shcheglov 4f77ddf8ce Start 5.13.0-dev, update CHANGELOG.md
There is a demand for a new analyzer version.
https://github.com/dart-lang/sdk/issues/52352#issuecomment-1546214969

I'm not ready to publish yet, lets wait for a couple of days after
landing `InvalidType`. But I'd like to record issues fixed.

Change-Id: I045ba904e3a229939fca5e37d63f16624cff8872
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303012
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-12 23:09:28 +00:00
Konstantin Shcheglov f4af6af85d Prepare for removing deprecated methods from ExtensionOverride.
The removal itself will happen in a separate CL, as a breaking change.
But we still had a few places that relied on `SimpleIdentifier` being visited.

Change-Id: I8f554cec77858cb8bc7deb29d98f0d6def8685ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303008
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-12 21:24:49 +00:00
Konstantin Shcheglov c0d33e45d1 Issue 52151. Fixes for reachability in switch patterns when unresolved / error type.
Bug: https://github.com/dart-lang/sdk/issues/52151
Change-Id: Ib56df1711cbfb7a593c7b16fd6a67e45baeabc3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302455
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-12 19:16:42 +00:00
Paul Berry 8d2b2a197d [parser] Ensure that list and map pattern parsing always makes progress.
In rare circumstances involving syntax errors, the `parsePattern`
method inserts a synthetic token but does not consume any
tokens. Usually when this happens it's not a problem, because whatever
method is calling `parsePattern` consumes some tokens, so the parser
always makes progress. However, when parsing list patterns, after
calling `parsePattern`, the parser would look for a `,`, and if it
didn't find one, it would supply a synthetic `,` and call
`parsePattern` again, resulting in an infinite loop. A similar
situation happened with map patterns, though the situation was more
complex because in between the calls to `parsePattern`, the parser
would also create synthetic key expressions and `:`s.

To fix the problem, when parsing a list or map pattern, after the call
to `parsePattern`, the parser checks whether any tokens were
consumed. If no tokens were consumed, it ignores the next token from
the input stream in order to make progress.

I also investigated whether there were similar issues with
parenthesized/record patterns and switch expressions, since those
constructs also consist of a sequence of patterns separated by tokens
and other things that could in principle be supplied
synthetically. Fortunately, parser recovery doesn't get into an
infinite loop in those cases, so I didn't make any further
changes. But I did include test cases to make sure.

Fixes #52352.

Bug: https://github.com/dart-lang/sdk/issues/52352
Change-Id: Idc8140236f6054deb1fd3c862036fe47dd84f30b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302803
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-05-12 18:43:39 +00:00
Brian Wilkerson d40890582c Convert uri completion tests
I am concerned about the tests marked with TODOs because I don't know
why the behavior changed. It's possible that the contributor is still
producing the suggestions but that they're being filtered out later.

I checked using the debugger, and they're not in the list of results
that we're getting back, so it seems likely that they represent real
bugs. If we just weren't detecting the bug before then we're good.

But I can't think how rewriting the tests could effect what the user
is seeing, so I think it's safe to make these changes.

Change-Id: If72042b7ec24b97994a12449c811213b8f708f72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303000
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-12 18:08:15 +00:00
Konstantin Shcheglov 42c79709a4 Separate isDynamicBounded() and isInvalidBounded().
Also includes https://dart-review.googlesource.com/c/sdk/+/302680
that was reverted because of adding extre diagnostics for Flutter.

Change-Id: I4cf7cedfcb67a5af226e609d279551fea0b0dee1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302844
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-12 15:12:38 +00:00
Konstantin Shcheglov 5e083e7dbc Issue 52360. Don't attempt to serialize PatternAssignment.
Bug: https://github.com/dart-lang/sdk/issues/52360
Change-Id: Iaf6fdbc602bd534147d88882fc39db69c3014585
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302882
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-12 15:02:23 +00:00
Konstantin Shcheglov 7312bf2437 Issue 52362. Fix NPE in AstNodeExtension.nodeCovering()
Bug: https://github.com/dart-lang/sdk/issues/52362
Change-Id: I47db23d809e30e5470f16abe1308bd11e74f3410
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302883
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-12 14:59:59 +00:00
Keerti Parthasarathy a071769acc Improve error message for async return type
fixes #33424

Bug: 33424
Change-Id: I8a0b7fb356ded813bf8736f6e52ccd365987e148
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302846
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-05-11 23:13:27 +00:00
Paul Berry 7968ea8b1f Remove unused parameter and return value from handleCaseHead.
These were introduced in
https://dart-review.googlesource.com/c/sdk/+/287601 to allow the
common front end to report back to the shared analysis logic when it
desugars a guard expression, so that flow analysis will properly
account for any promotions made by the guard expression; previously,
if a guard expression got desugared by the front end, promotions
performed by the guard would be lost.

In https://dart-review.googlesource.com/c/sdk/+/298840, we've switched
to a more general technique for ensuring that promotions performed by
the guard will not be lost: now the `dispatchExpression` method uses
`FlowAnalysis.forwardExpression` to compensate for the differences in
the conventions of the CFE and the shared logic, so that the shared
logic no longer needs access to the desugared expression. So the
`head` parameter (and the associated return value) are no longer
needed.

In a future change, I plan to adjust the CFE conventions to match
those of the shared logic, so that `FlowAnalysis.forwardExpression`
won't be needed at all (see
https://github.com/dart-lang/sdk/issues/52189).

Change-Id: I686d1d5b7e4c9db353f583c38792274451f9f8bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302366
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-05-11 20:58:22 +00:00
Emmanuel Pellereau d3c7e183e9 Revert "Issue 35828. Don't report COULD_NOT_INFER when InvalidType, make it a subtype of everything."
This reverts commit 838c926f64.

Reason for revert: breaks google3. See b/281948666

Original change's description:
> Issue 35828. Don't report COULD_NOT_INFER when InvalidType, make it a subtype of everything.
>
> Bug: https://github.com/dart-lang/sdk/issues/35828
> Change-Id: Ie7757cb2e0cbc0cfdd1530b75f34ffb3dd3156dd
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302680
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>

Bug: https://github.com/dart-lang/sdk/issues/35828
Change-Id: I05ddcf7657069b1e889b5b0019faaf7301f6643b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302781
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-11 14:00:06 +00:00
Konstantin Shcheglov 838c926f64 Issue 35828. Don't report COULD_NOT_INFER when InvalidType, make it a subtype of everything.
Bug: https://github.com/dart-lang/sdk/issues/35828
Change-Id: Ie7757cb2e0cbc0cfdd1530b75f34ffb3dd3156dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302680
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-11 01:05:51 +00:00
Konstantin Shcheglov 6c995aab3f Issue 26710. Don't report NON_CONSTANT_DEFAULT_VALUE when InvalidType.
Bug: https://github.com/dart-lang/sdk/issues/26710
Change-Id: I43e68aa46de338c3ebcfafa5eec21eebeab3be54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302660
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-11 01:05:47 +00:00
Kallen Tu 9c34ff75db [analyzer] Produce error when omitting base/final/sealed on base/final superclasses through legacy libraries.
When a post-feature library implements a pre-feature library declaration that has a final core library class as a super declaration, it should not produce a base/final/sealed transitivity error. Subclasses of a base core library class will still emit this error.

Otherwise, if base/sealed/final is omitted in a non-implement case, we want to report these errors.

Bug: https://github.com/dart-lang/sdk/issues/52315
Change-Id: Icdd4f63f69b061be5eabc7fd30b703d0358018a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302365
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-10 22:05:59 +00:00
Konstantin Shcheglov a3956e49d0 Use InvalidType instead of DynamicType when unresolved.
Bug: https://github.com/dart-lang/sdk/issues/36697
Change-Id: If982ca46030959160f21950c5b5e3127895d937b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300181
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-10 20:38:48 +00:00
pq 0cfb3611d4 fix result use checking in record literals and when clauses
Change-Id: I9762fd7329c2d6d98033f99716fac9c21fab17f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-05-10 16:32:47 +00:00
Konstantin Shcheglov be4e79edd7 Issue 52313. Support for FutureOr in canBeSubtypeOf().
Bug: https://github.com/dart-lang/sdk/issues/52313
Change-Id: I95792ce457e7a1f3f9d8d4f61565b28a2eb0c004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302442
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-10 15:42:05 +00:00
Konstantin Shcheglov c4aa75408d Issue 52327. Don't report SDK_VERSION_SINCE when pubspec.yaml has exact version of SDK that is greater than the required.
Bug: https://github.com/dart-lang/sdk/issues/52327
Change-Id: I20b86173d59fb725cb715b624348d5ddd289e0f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302443
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-10 15:41:54 +00:00
Konstantin Shcheglov 4a62426d1d Prepare to publish analyzer 5.12.0 and _fe_analyzer_shared 60.0.0
Change-Id: Iea968efec63034ed3830dbc46ad0a29158dd9fcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302363
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-09 23:35:48 +00:00
Michael Thomsen 152296e642 Cleanup experiment flags formatting:
- Move down shipped 3.0 flags
- Sort all flags consistently

TEST=Manually verified

Change-Id: I21c209df4ff11322512e50a2be666293b5a9743f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302323
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2023-05-09 21:08:41 +00:00
Paul Berry a83a1a4c55 Revert "Update comments and readmes to specify dart run --no-pub when necessary."
This reverts commit d2df7ce24a.

Reason for revert: https://dart-review.googlesource.com/c/sdk/+/291500 was reverted

Original change's description:
> Update comments and readmes to specify `dart run --no-pub` when necessary.
>
> Now that https://dart-review.googlesource.com/c/sdk/+/291500 has
> landed, `dart run` now tries to invoke `dart pub` before execution.
> This doesn't work when running scripts inside the SDK, because the SDK
> doesn't use pub to get its dependencies.  So scripts in the SDK now
> need to be run with `--no-pub`.
>
> Change-Id: Ic320b717b2d45278cd26d373ae0823c2935ce102
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292720
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

Change-Id: I6c13510abde17f71694f362a8071c9c7fa519a88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302364
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-09 20:38:49 +00:00
pq b0b393773f fix unused result checking for switch expression cases
Fixes: https://github.com/dart-lang/sdk/issues/52314

Change-Id: I02a952ee94084599273193b509987f46ac6198e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302381
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-09 19:38:35 +00:00
Konstantin Shcheglov 4f7295ad26 Record elements and types parts of missing patterns for AddMissingSwitchCases fix.
Bug: https://github.com/dart-lang/sdk/issues/51985
Change-Id: I48e04e992ccab5cb5dedb5df328ba13ffcf6b560
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302200
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-09 16:29:20 +00:00
Chloe Stefantsova 40d99bc981 [cfe] Remove extra conditions on await-for in non-async body check
Additionally, report the error on the 'await' keyword instead of 'in'

Change-Id: I0ccd156f19997eb18b5df004a75f86e616b23864
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301021
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-09 06:56:44 +00:00
Kallen Tu 6de1afdb3a [analyzer] Disallow implementing a legacy library subclass of a final class.
Checks an interface's supertypes for final classes and produces an error if the implementing bypasses a legacy library.

This behaviour should only happen when a post-feature library implements
a pre-feature library declaration that has a final class as a super
declaration.

Similar error to https://dart-review.googlesource.com/c/sdk/+/298320

Bug: https://github.com/dart-lang/sdk/issues/52078
Change-Id: Ie16edb2b231957dad7502fdab3d5faba93bc6773
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300861
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-08 23:16:53 +00:00
Konstantin Shcheglov 1e626dc929 Issue 52306. Don't report UNNECESSARY_IMPORT when deprecated exports.
Bug: https://github.com/dart-lang/sdk/issues/52306
Change-Id: I20a36ea355df463857b56cb05bcef0ef72f6850d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302080
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-08 19:50:29 +00:00
Konstantin Shcheglov 2e6bdc29de Add InvalidType, InvalidTypeImpl, but don't resolve to it yet.
I ran the CL that does resolve with it in google3, it is mostly
green, but there are a few clients that extend TypeVisitor directly.
So, I want to publish the interface `InvalidType` first, update the
clients, and only then update the resolution.

Bug: https://github.com/dart-lang/sdk/issues/36697
Change-Id: I1f1c995a36849ebbde2c526bb8761d86be87b4ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301481
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-08 19:48:03 +00:00
Paul Berry 3713c0e264 Patterns parser: prohibit variable/identifier patterns named when/as.
In https://dart-review.googlesource.com/c/sdk/+/299400, the parser was
adjusted so that it no longer accepts `when` and `as` as the names for
variable patterns in cases where there is a possible ambiguity
(e.g. `int when` is not accepted as a pattern because `int` is a
legitimate pattern, therefore `when` could introduce a guard
clause). This change further prohibits `when` and `as` from being the
names of variable patterns or identifier patterns even in the case
where there is no ambiguity. This is in line with the discussion at
https://github.com/dart-lang/sdk/issues/52199#issuecomment-1526297771,
and the spec change at
https://github.com/dart-lang/language/pull/3033.

Three new error codes are introduced, to cover the three circumstances
in which `when` or `as` might be used illegally: in a declared
variable pattern, in an assigned variable pattern, or in an identifier
pattern. I've also added analyzer tests to ensure that the parser
recovers from these errors nicely. Unfortunately, nice error recovery
is only feasible in the non-ambiguous cases.

I've also updated the language test expectations in
`tests/language/patterns/version_2_32_changes_error_test.dart` to
reflect the new error messages, and added a few more examples of uses
of `when` and `as` that are still permitted.

Fixes #52260.

Bug: https://github.com/dart-lang/sdk/issues/52260
Change-Id: I229f627aa639659c30b83c74895759207da279f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301482
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-05-08 19:06:02 +00:00
Konstantin Shcheglov 757d9ae199 Issue 52280. Use the URI as LibraryElement.toString()
Bug: https://github.com/dart-lang/sdk/issues/52280
Change-Id: I15fa5a9cdc2017d91f6d75da17430c060624695e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301726
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-08 15:41:23 +00:00
Konstantin Shcheglov 44ba2eba08 Issue 52258. Ignore 'int' and 'double' pairs, are the same in JavaScript.
Bug: https://github.com/dart-lang/sdk/issues/52258
Change-Id: I01f167bf597f11cb8dec7864c3074d16ad44c2d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301725
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-08 15:39:52 +00:00
Daco Harkes 8beb778e64 [analyzer/ffi] Fix spurious FFI errors
Closes: https://github.com/dart-lang/sdk/issues/52298
Change-Id: Ibfccd34a877d5786f4720790b5ff88dcc643c9d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-05-08 15:16:05 +00:00
Konstantin Shcheglov c63263cbf5 Issue 51855. Add debug output.
Bug: https://github.com/dart-lang/sdk/issues/51855
Change-Id: Ifd8f3cf1f4e82536b475fb7460c27d1ba73672e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301732
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-08 14:47:32 +00:00
Konstantin Shcheglov 036b8cafad Add AnalysisError.tmp() constructor, deprecate the default one.
Bug: https://github.com/dart-lang/sdk/issues/51985
Change-Id: I1204c71a4c5ea62d32d65662ecb5274dacb0bfae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301730
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-08 14:39:29 +00:00
Konstantin Shcheglov f572144809 Issue 52271. Report FINAL_CLASS_EXTENDED_OUTSIDE_OF_LIBRARY when via library before class-modifiers.
Bug: https://github.com/dart-lang/sdk/issues/52271
Change-Id: I94049f8702647fc604c42ce353afce9d19322d8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301506
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-06 17:16:28 +00:00
Konstantin Shcheglov f90c3d0423 Issue 52272. Report DEPRECATED_MIXIN_FUNCTION in more places.
Bug: https://github.com/dart-lang/sdk/issues/52272
Change-Id: I02133f8685adf6a1e4fa16288948cc31afeb1bd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301560
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-05 20:02:28 +00:00
Konstantin Shcheglov 4d6f49b1cd Update ExtensionOverride to use ImportPrefixReference and name token.
Change-Id: Ifc5852c775a95908992d33a7949b4f4bea396d66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299920
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-05 15:42:36 +00:00
Konstantin Shcheglov 40de1ab1ab Issue 46514. Report an error for using extension methods in a prefix or binary constant expressions.
Bug: https://github.com/dart-lang/sdk/issues/46514
Change-Id: I59ed3bd754043302632f31aedeaedd7824b8a8c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301505
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-05 02:31:19 +00:00
Konstantin Shcheglov b06b994a4e Use errorType for element type when an error in for-in.
Change-Id: I8be4c1521a819f26d249d688f72dc672ee4994fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300561
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-03 21:17:08 +00:00
Srujan Gaddam c4d354dc2a Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations"
This reverts commit 4919729f00.

This CL also adds back in logic to handle older package:js versions to avoid
failures in our static checking. It also supports dart:js_interop's @JS
annotation since it can now be used for @staticInterop classes.

CoreLibraryReviewExempt: Reland of backend-specific library changes.
Change-Id: I104653a9a6b2593f6bab658808287e2074c18550
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294130
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-02 15:24:18 +00:00
Sam Rawlins fba03c7d44 [analyzer] Use firstWhereOrNull in Element
Also standardize on arrow functions vs not, to what seems idomatic in
this file.

Change-Id: I73f9a71f928e8d02cdabbc0500c8dc150b45172e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300163
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-01 20:15:08 +00:00
Sam Rawlins be1e7497c8 [analyzer] simplify AbstractClassElementImpl.supertype
Change-Id: I68eda760a8e55b537d5acbc1c62bfe29e4a32309
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300142
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-01 19:52:58 +00:00
Konstantin Shcheglov f8eb704f4e Rename to NamedTypeResolutionTest.
Change-Id: I6e840177e343d9cf08c3a18226849749a067aa7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300340
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-05-01 18:02:09 +00:00
Konstantin Shcheglov ec330b47de Deprecate 'DartType.isDynamic', use 'is DynamicType' instead.
Change-Id: Ia3660a0d38f01a590dd3e034f40dbdb5a432638a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300042
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-01 16:09:08 +00:00
Konstantin Shcheglov e4d754d5b6 Issue 47915. Don't build DefaultParameterElementImpl for formal parameters that are not allowed to have default values.
Bug: https://github.com/dart-lang/sdk/issues/47915
Change-Id: I708775ca29bf9efdfdf798eb4b622f1308f2b00c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300140
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-01 16:05:48 +00:00
Konstantin Shcheglov 6af3a8dc2c Add 'provideLanguageVersion' option to BlazeWorkspace.
Bug: https://buganizer.corp.google.com/issues/279909837
Change-Id: I8e094899eae10323d9b2b608da0815442b82cf49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299860
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-28 19:59:12 +00:00
Konstantin Shcheglov 4756d077ed Update NamedType to use ImportPrefixReference and name token.
Using Identifier expression inside NamedType does not make sense.

Change-Id: I4a61d2b472fd66fb7c5e6e92a80cccb391b06d49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294920
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-28 17:31:46 +00:00
Paul Berry 637dd76c7f Patterns parsing: fix ambiguity resolution for when and as.
This change fixes parsing of case clauses such as:

    case foo when !flag:

Constructions like this require some lookahead in order to parse
correctly, because the token `when` is valid both as an identifier and
as a part of the grammar for a case clause. Therefore, at the time
`foo` is encountered, the parser must decide whether it is looking at
a variable pattern (`foo when`, where `when` is the name of the
variable) or an identifier pattern (`foo`, where `when` begins the
case's guard clause). Previous to this fix, the algorithm for
disambiguating these two choices was as follows:

- If the token sequence starting at `foo` looked like a type, and the
  token that follows was an identifier, the parser assumed it was
  looking at a variable pattern with a type; otherwise it assumed it
  was looking at an identifier pattern.

- EXCEPT that if the token that followed the supposed type was `when`
  or `as` (both of which are valid identifiers), then it probed
  further:

- If the token that followed `when` or `as` was a token that could
  legitimately follow a pattern, then it assumed that it was looking
  at a variable pattern with a type. (The tokens that could
  legitimately follow a pattern are `,`, `:`, `||`, `&&`, `)`, `}`,
  `]`, `as`, `when`, `?`, `!`).

- Otherwise it assumed that it was looking at an identifier pattern.

This didn't fully disambiguate, because the third bullet didn't
account for the fact that the tokens `as`, `when`, and `!` could
_either_ legitimately follow a pattern _or_ legitimately begin an
expression (or, in the case of `when`, a type), therefore constructs
like the following were incorrectly parsed:

- `case foo when as:` (where `as` is a local boolean variable)
- `case foo when when:` (where `when` is a local boolean variable)
- `case foo when !flag:` (where `flag` is a local boolean variable)
- `case foo as when:` (where `when` is the name of a type)

The solution is to simplify the disambiguation logic so that if if the
token that follows the supposed type is `when` or `as`, then the
parser assumes that it's looking at an identifier pattern, _not_ a
typed variable pattern.

The consequence of this is that the above four constructions are
parsed correctly; however it is no longer possible for a typed
variable pattern to name a variable `when` or `as`.

For consistency we would like to prohibit _any_ variable pattern from
naming a variable `when` or `as`, however to keep this change as small
as possible (and reduce the risk involved in a possible cherry-pick)
that will be postponed until a later CL.

Fixes #52199.

Bug: https://github.com/dart-lang/sdk/issues/52199
Change-Id: Ibab9b92f01e3e4020d7d64f1ff000a9b964a4564
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299400
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-04-28 13:22:28 +00:00
Konstantin Shcheglov 7f503e3688 Issue 52202. Fix crash when object pattern type is potentially nullable.
Bug: https://github.com/dart-lang/sdk/issues/52202
Change-Id: I54068a58f68f46c3d75c1586e6ed575b361a22fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299380
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-04-28 03:20:39 +00:00
Konstantin Shcheglov 0f4275a443 Issue 52197. Remove null assert from getEnumElementValue()
I see a crash like this from external users.

Bug: https://github.com/dart-lang/sdk/issues/52197
Change-Id: I5b18552ae1db50c7a103ee6b04f36d0ade8c6f5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299180
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-27 21:22:48 +00:00
Konstantin Shcheglov d838d1a08a Issue 52191. It is not an error to use a void typed expression in SwitchExpressionCase.
Bug: https://github.com/dart-lang/sdk/issues/52191
Change-Id: I2cea3260ad63a0c59399f02dadb99bb09a944623
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299200
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-27 21:22:29 +00:00
Konstantin Shcheglov a0218e916c Issue 52176. Support for ojbect pattern in 'Create Getter' and 'CCreate Field'.
Bug: https://github.com/dart-lang/sdk/issues/52176
Change-Id: Ic9c97bec1981c5613b23206e872f6f708d53792d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298920
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-27 20:52:39 +00:00
Konstantin Shcheglov c13acbf1dd Issue 52136. Report USE_OF_VOID_RESULT for SwitchExpression.
Bug: https://github.com/dart-lang/sdk/issues/52136
Change-Id: I3a3b8f45419c57deec77deae37cd5f98481debeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-26 16:12:48 +00:00
Konstantin Shcheglov 80d26df2fd Issue 52160. Report BASE_CLASS_IMPLEMENTED_OUTSIDE_OF_LIBRARY for implementing 'base' via 'extends'.
Bug: https://github.com/dart-lang/sdk/issues/52160
Change-Id: I47a72021a002663d04fd8ea14c11a012917e8a8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-25 20:19:38 +00:00
Konstantin Shcheglov 79bf3eedd6 Run UseOfVoidResultTest with null safety enabled.
Bug: https://github.com/dart-lang/sdk/issues/52136
Change-Id: I0a77a81d0a558e8b2450e91e6156d5fab03579a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298300
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 20:14:08 +00:00
Konstantin Shcheglov 00d841ee99 Issue 52060. Fix reporting CONSTANT_PATTERN_NEVER_MATCHES_VALUE_TYPE for Null vs. nullable FunctionType.
Bug: https://github.com/dart-lang/sdk/issues/52060
Change-Id: I5373a9a73396fbf49562131f5f801d1bceeb65f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298280
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 20:09:28 +00:00
Konstantin Shcheglov b81fd66ed5 Issue 52164. Include enums and mixins into types of a sealed class.
Bug: https://github.com/dart-lang/sdk/issues/52164
Change-Id: Icd6ac232d6356b7e05995b79e5f7d8b33b88a719
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298260
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 20:01:52 +00:00
Konstantin Shcheglov 018dadcf5b Resolve the whole unit in resolveForCompletion() when the node is a directive.
There is a quite complicated logic in resolving directives and walking
augmentations and parts. And we don't expect users write a lot of code
in directives, so there is less need for optimizations than when typing
in method bodies.

Change-Id: Id38e90f09eb5c1e84be8fc28ed4211d03762d2e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-25 20:01:25 +00:00
Danny Tuppeny c4d2d2d7c2 Reland "[analysis_server] Use fixDataYamlFolder constant instead of string literals"
This is a reland of commit ccb02fa8fc

Original change's description:
> [analysis_server] Use fixDataYamlFolder constant instead of string literals
>
> Follow-up from https://dart-review.googlesource.com/c/sdk/+/296801.
>
> Change-Id: I72ea8a42ec64c4bd6c6cee021a1464167ec368e6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296862
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I202392de3444556dc2baa9ed9e1b82c3a1ede4aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298060
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 14:17:00 +00:00
Konstantin Shcheglov 34c18da5eb Prepare to publish analyzer 5.11.1 and _fe_analyzer_shared 59.0.0
Bug: https://github.com/dart-lang/sdk/issues/52159
Change-Id: Ia603e77694d11af1045a94bdf00468d02eb5f6af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-25 01:15:05 +00:00
Danny Tuppeny 86e3305538 Reland "[analysis_server] Analyze fix data in fix_data folder"
This is a reland of commit bbacf39e9c

Original change's description:
> [analysis_server] Analyze fix data in fix_data folder
>
> Fixes part of https://github.com/dart-lang/sdk/issues/52126.
>
> Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I571c1e4f87fdf0095d003d496f3c5d88e5cf0ff8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297940
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 00:08:54 +00:00
Konstantin Shcheglov 82cffbb38b Prepare to publish analyzer 5.11.0 and _fe_analyzer_shared 59.0.0
Change-Id: I1d841f7c12698e56bd99ed109e58795172499ed1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297842
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-24 22:08:12 +00:00
Konstantin Shcheglov 903be31b05 Apply nullabilitySuffix to interfaces / mixins / superclassConstraints / superclass.
Bug: https://github.com/dart-lang/sdk/issues/52133
Change-Id: Ib32d10d7736c59f93fdb1d6eb79851f3e44457b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297400
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-24 17:56:40 +00:00
Johnni Winther 3a5b06a9c3 [_fe_analyzer_shared] Handle private names in exhaustiveness checking
Closes #52041

Change-Id: I8824aeb84eb6357bd47a6111217a273c883a68d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297462
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-04-24 14:31:49 +00:00
Chloe Stefantsova 6b0acfecc1 [cfe] Put patterns in the scopes of their declared variables
Closes https://github.com/dart-lang/sdk/issues/51971

Change-Id: I8ba634e7303bafdb1895c50970fbc80321f4bf6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296581
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-04-24 07:30:00 +00:00
Zach Anderson e34daa818b Revert "[analysis_server] Analyze fix data in fix_data folder"
This reverts commit bbacf39e9c.

Reason for revert: Causing flutter/engine to fail to roll into flutter/flutter. See https://github.com/flutter/flutter/pull/125363.

Original change's description:
> [analysis_server] Analyze fix data in fix_data folder
>
> Fixes part of https://github.com/dart-lang/sdk/issues/52126.
>
> Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I109a4b2c596ad22d73eaf0ac3e25f53a35ba5e28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297320
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2023-04-22 22:10:12 +00:00
Zach Anderson 7575e2c5be Revert "[analysis_server] Use fixDataYamlFolder constant instead of string literals"
This reverts commit ccb02fa8fc.

Reason for revert: Blocking revert in https://dart-review.googlesource.com/c/sdk/+/297320

Original change's description:
> [analysis_server] Use fixDataYamlFolder constant instead of string literals
>
> Follow-up from https://dart-review.googlesource.com/c/sdk/+/296801.
>
> Change-Id: I72ea8a42ec64c4bd6c6cee021a1464167ec368e6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296862
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I8ed39fc343b9121c40de83038e97c43cac669ca1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297321
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2023-04-22 21:22:47 +00:00
Konstantin Shcheglov 529adda42e Issue 52131. Find implicit constructor invocations from other constructors.
Bug: https://github.com/dart-lang/sdk/issues/52131
Change-Id: I7f28e4664f18196f978cb9dd38f878b1240d46a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297080
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-21 22:04:16 +00:00
Paul Berry 5d7dd58d41 Ignore TODO in pkg/analyzer and pkg/analysis_server.
The analyzer team has decided to adopt the convention of using `TODO`
comments to document long term issues that should persist in the
codebase, and `FIXME` comments to document short term issues that need
immediate attention.  They may even consider adding a presubmit hook
to ensure that `FIXME` comments are only used during local
development.

Accordingly, it makes sense to suppress `TODO` comments from being
surfaced to the IDE "problems" view (since there are hundreds of them,
and they're not immediately actionable).  This makes VSCode's
"problems" view much more usable in "tree" mode.

Change-Id: I11a0c59132fb98c1c86fb4adf22d1fdf3b547c80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295662
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-21 19:16:04 +00:00
Danny Tuppeny ccb02fa8fc [analysis_server] Use fixDataYamlFolder constant instead of string literals
Follow-up from https://dart-review.googlesource.com/c/sdk/+/296801.

Change-Id: I72ea8a42ec64c4bd6c6cee021a1464167ec368e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296862
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-21 18:50:50 +00:00
Danny Tuppeny bbacf39e9c [analysis_server] Analyze fix data in fix_data folder
Fixes part of https://github.com/dart-lang/sdk/issues/52126.

Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-21 15:18:56 +00:00
Paul Berry 600fccb9bb Rework exhaustiveness witness generation to allow analyzer to capture import info.
In order for an analyzer quick fix to aid the user in correcting
exhaustiveness errors, it needs to know not just the text of the
witness pattern that needs to be inserted, but also which elements are
referenced by the identifiers in that pattern.  This will allow it to
add in imports if the user's code doesn't yet import the necessary
library, or insert import prefixes in the case where the user is
already importing the necessary library in a prefixed fashion.

To reduce the effect on the exhaustiveness logic (which was designed
with the intention of building up the witness pattern into a
StringBuffer), we introduce a new type, `DartTemplateBuffer`, which
behaves similarly to StringBuffer but also captures the necessary
semantic information so that the analyzer will be able to fix up
imports in an appropriate way.

This change is mostly isolated to the _fe_analyzer_shared package; it
doesn't add the necessary logic to the analyzer to capture the
elements; it simply plumbs them up to the API boundary between the
packages.  Future CLs will add the necessary analyzer logic to make
use of the information.

Change-Id: I7c030fc49a2510acbefd6aeb567e0e7b7102855a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296385
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-04-20 23:30:21 +00:00
Kallen Tu 199feac353 [analyzer/cfe] Update abstract sealed error message.
State more explicitly that sealed classes are abstract and lead the
user to a better fix with the error message.

Bug: https://github.com/dart-lang/sdk/issues/52073
Change-Id: Id24c6cb187ee5497ca2819f930c48ff5aa8d07fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296025
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-04-20 19:54:30 +00:00
Konstantin Shcheglov e8622f2d63 Issue 52059. Don't suggest final/var in ObjectPattern in ForEachPartsWithPattern, suggest getters instead.
Bug: https://github.com/dart-lang/sdk/issues/52059
Change-Id: If5e1c40fa75735077b2b77a5941d16fe2c767f3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296501
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-20 16:14:58 +00:00
Konstantin Shcheglov 493f36690f Allow analysis_server/ access not yet imported libraries from src/ in analyzer/.
Change-Id: I0b4119965bdb83149117a02f885fe8362f69915f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296502
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-20 14:32:38 +00:00
pq 4451d5d9f5 follow ups from https://dart-review.googlesource.com/c/sdk/+/296066
(The last change was prematurely merged.)

Change-Id: Idc161ef596fa43927cf7eda223635a798d3292af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296402
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-19 20:13:03 +00:00
Konstantin Shcheglov d84f9dca32 Ensure that ExecutableMember.returnType uses the same type parameters.
Change-Id: I72d900da7e0d6b791e7801af72961cf4c23c4fc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296340
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-19 19:01:57 +00:00
Konstantin Shcheglov dc34fe9f86 Deprecate IfElement/IfStatement.condition, use 'expression'.
Change-Id: If43b4b71a21fd256ce8d1367d4b233e1cff764b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296122
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-19 17:17:28 +00:00
Konstantin Shcheglov ad30add7a3 Don't use PubWorkspace for 'third_party/dart' locations.
These should be treated as BlazeWorkspace.

Bug: https://buganizer.corp.google.com/issues/273584249
Change-Id: Id7bf03d14d3304eb062be0d539cfac0c282ecec6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-19 17:16:51 +00:00
Konstantin Shcheglov cef5bcb602 Remove '@experimental' from declarations related to records and patterns.
Change-Id: I4db54e3097c343ec72e041f78df2b38b1835853e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-19 00:51:58 +00:00
Konstantin Shcheglov 000655e4d3 Support sealed classes in canBeSubtypeOf()
Bug: https://github.com/dart-lang/linter/issues/4280
Change-Id: Iab92670d7c5db535968b4fe4ac26a5777e1bf6ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295801
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-18 20:02:58 +00:00