Commit Graph

10122 Commits

Author SHA1 Message Date
Konstantin Shcheglov 09550b33fc Issue 57035. Fix for exception when asking class alias constructors.
Bug: https://github.com/dart-lang/sdk/issues/57035
Change-Id: I48aa20815b56c49f08e22509126f74891e694644
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393960
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-06 20:24:39 +00:00
Konstantin Shcheglov 4f20171f69 Elements. Use more impl in impl and tests.
Change-Id: Ibef3504c701fa3f37eb9078058113d8e44f05f04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393585
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-06 16:51:02 +00:00
Konstantin Shcheglov 53bf3ff846 Elements. Rename to ClassElementImpl2, etc.
Change-Id: I94119f60b5bf01e52cf348a7c67f2b4a5ba62900
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393583
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-05 18:42:21 +00:00
Konstantin Shcheglov 7b9d11a6a4 Elements. Write mixins / interfaces / etc of InstanceElement2.
Change-Id: I402d76450bb06a74580292777dae4514c2685e75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393580
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-05 02:36:18 +00:00
Konstantin Shcheglov 19cac1c907 Elements. Remove 'normalParameterNames' and 'optionalParameterNames' from FunctionType.
Change-Id: I934dca9f635411b71add032a3fc607dddf7de11a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393362
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-04 23:58:32 +00:00
Konstantin Shcheglov 4f6b07c25e CQ. Remove available declarations.
Bug: https://github.com/dart-lang/sdk/issues/55281
Change-Id: Ie8d2a7f3d5ea9408320312d49eb67561ca463289
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393480
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-04 21:30:08 +00:00
Konstantin Shcheglov 4096db4d51 Elements. Create loadLibrary() function with reference, lazily.
Related to https://dart-review.googlesource.com/c/sdk/+/393164

Change-Id: Ia448ff42c9de538be9a8f6f2101dff0c949671d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393260
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-11-04 17:19:46 +00:00
Jens Johansen 817882c36b [parser] Recover missing identifier in new style typedef
Before, when parsing a new style typedef without an identifier (e.g.
`typedef = whatnot`) it concluded that the token after the equal-sign
wasn't an equal sign an that it thus had to be an old style typedef,
followed by recovery there.

This CL makes the recovery insert an identifier after `typedef` (what
the recovery of the old style actually did too), and then parse it as a
new style typedef.

This causes the previous many errors to just be `Expected an identifier,
but got '='.`

It is furthermore verified that the parsing of such a case is ~the same
as when having an indentifier.

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

Change-Id: I5cde1f29839555b1d6027a7d040dc6f60ac614a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392560
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-11-04 11:18:38 +00:00
Konstantin Shcheglov 1a0273672a Elements. Build TopLevelFunctionElementImpl during building elements.
Give it a reference.

Change-Id: Ie1189a18e9d2794d37e530cbbb01ddd86b78a16e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393164
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-01 22:21:00 +00:00
Konstantin Shcheglov a868303290 Elements. Remove FragmentName, inline as name2 / nameOffset2.
Change-Id: If238cd71867501a39e243261228d137f925db1dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-01 18:56:26 +00:00
Sam Rawlins 784af8f704 DAS plugins: track lint rule configuration by name
* PluginConfiguration.ruleConfigs is now a Map instead of a List,
  mapping analysis rule names to each RuleConfig. This makes it more
  straightforward (and theoretically more performant) for the Registry
  to determine the set of enabled analysis rules. The primary parsing
  code, `parseLinterSection`, also returns a mapping now.
* This merges seamlessly into `AnalysisOptionsImpl`'s call to
  `parseLinterSection`.

This is most of the refactoring work found in
https://dart-review.googlesource.com/c/sdk/+/392981, but without the
change to allow warnings to be disabled.

Change-Id: I4d1e6791da83ad370c18a15e9e3bb85b1daed58d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-11-01 16:28:30 +00:00
Konstantin Shcheglov c17dd356c1 CQ. Remove most of DeclarationsTracker.
Keep only enough to support DartdocDirectiveInfo.

Change-Id: I228d771b866bd7f0a903b62064f058c9edd04bee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393020
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-01 15:07:48 +00:00
Konstantin Shcheglov 2d0eedc100 Elements. Keep only AugmentedInstanceElementImpl and subclasses.
Having single implementation of `ClassElement2` (and other elements like it) makes the implementation easier now, and simplifies future changes.

Change-Id: Ifd38a8738fff99b7ac0b387140fdd623be18be01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392780
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-01 14:58:14 +00:00
Johnni Winther bdacb7d034 [_fe_analyzer_shared] Add evaluateExpression
This adds a helper method that evaluates an [Expression] based on
the semantics that can be deduced from the syntax.

Change-Id: I1b54ee03c1380d337969671133179aa557702a9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392440
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-11-01 09:26:44 +00:00
Brian Wilkerson 5ef250a2bf Rework the new element model so that all elements have fragments
Change-Id: Ic4fc0368cabc5fa8dfc21c958e1619777f2701b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392541
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-31 23:23:39 +00:00
Kallen Tu 00e4c92a64 [flow] Part 3 Issue 3658 Avoid writing promotion information for postfix inc/dec expressions.
Postfix increment and decrement expressions should not be saving any promotion information.

An example of where saving the promotion information after the write is unsafe is:
```
class A {
  A operator +(int i) {
    return new B();
  }
}

class B extends A {}

main() {
  A x = A();
  if ((x++) is B) {
    // x should not be B
  }
}
```

This change is only for the analyzer because the CFE does something different (converts the postfix increment/decrement into a let expression).

Bug: https://github.com/dart-lang/language/issues/3658
Change-Id: Ic22f69bf79da66965908ade80bdf70399f0bcaa3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391494
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2024-10-31 22:15:14 +00:00
Danny Tuppeny 27b52a3f82 Add languageVersion to CompilationUnit and make non-null
Change-Id: Ice6f866929f1f028d9b4e64685c2e815a08279f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392000
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-31 18:49:03 +00:00
Sam Rawlins 09b4ec7445 analyzer: Fix 40 broken comment references
Change-Id: I91c6ae9473cc6cdde1b5131a349c2701e51a1aaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392800
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-31 16:28:07 +00:00
Sam Rawlins 52001ff5ac analyzer: Support a list of included analysis options
Fixes https://github.com/dart-lang/sdk/issues/47256

See specified behavior at https://github.com/dart-lang/sdk/issues/47256#issuecomment-2374880529

Additionally:

* Make AnalysisOptionsProvider.sourceFactory private and final,
  which allows for promotion, yay!

Change-Id: I26e0e73c661d48189078be95ff544fe8dfb7a86d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-30 22:08:49 +00:00
Konstantin Shcheglov 84e15e9efb Issue 56355. Fix token cycle via 'previous'.
Bug: https://github.com/dart-lang/sdk/issues/56355
Change-Id: I1ee7f837dc8beed9bb2ed1f27c45108345e7cceb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-29 20:12:41 +00:00
Konstantin Shcheglov aec93bfaad Elements. Use 'firstFragment' instead of 'declaration' in AugmentedInstanceElement and subtypes.
Change-Id: Idc3812ebc51f0bf92f467f21d91f7f4ecb3171e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392241
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-29 20:02:00 +00:00
Sam Rawlins 97871aeab5 analyzer: Use less AnalysisOptionsImpl
In many cases, AnalysisOptions is sufficient.

* ResolvedCorrectionProducer will be public API for someone writing an
  analyzer plugin; it should not expose an AnalysisOptionsImpl. Luckily
  the only need for the Impl, today, is in the "ignore diagnostic" fixes
  so we can cast in there. (We could also expose the `file` and the
  `unignorableNames` fields.)
* Some other spots only cast in order to access one of the 'strict'
  fields, but all of those have been made public.
* AnalysisOptionsImpl.enabledLegacyPluginNames can be made final.
* Many other users don't need AnalysisOptionsImpl, or only need it to
  pass it to other code that _does_ need it. In many of those cases it
  makes sense to look at an object as an AnalysisOptions, and let the
  code that needs a field from Impl to do a cast.

Change-Id: I3640934fb9d93c9b95f15a22457af604e420c7a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-29 14:22:58 +00:00
Konstantin Shcheglov 106489ae1c Elements. Add reference for enum, extension, extension type elements.
Change-Id: I1b204a256bf8845959ccde1de5a755994b3ff105
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392101
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-28 21:21:29 +00:00
Sam Rawlins bc58f69e53 analyzer: Move AnalysisOptionsImpl out of the generated directory
None of the code in AnalysisOptionsImpl or AnalysisOptionsBuilder is
changed.

Change-Id: I0d3253d80fdcd624c73720c35ece9d23a2582071
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392180
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-28 21:03:33 +00:00
Sam Rawlins 155a64c1b7 DAS plugins: Allow plugin rules to be disabled by default
This bumps the Registry class to be able to take "rules that are enabled  by default" and "rules that need to be explicitly enabled", "lint rules" and "warning rules". Next is to improve the classes.

Add parsing for the top-level `plugins` section, and
`PluginConfiguration` class to hold this data, and
`get pluginConfigurations` on AnalysisOptions.

Rename `parseLintRuleConfigs` to `parseLinterSection` to align better
with the other functions in engine.dart.

Rename `_ruleConfigs` function to `parseRulesSection`.

Change-Id: Ib93b7548bfb13cc94381971a5a2780a5dc81e9f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-28 01:42:02 +00:00
Konstantin Shcheglov 74a2bc7af4 Elements. Add reference for MixinElement2.
Change-Id: I8cce4acc8f499754ff8d5e96930ae1b5d86943a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392061
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-25 20:13:48 +00:00
Konstantin Shcheglov d05ea2ff50 Elements. Start moving toward element builders.
Change-Id: Iad5abe08363a658f48a24d7ba8103c5102314508
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391497
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-25 16:02:41 +00:00
Chloe Stefantsova 253e715f83 [analyzer] Report warnings on expressions with non-nullable types
Part of https://github.com/dart-lang/sdk/issues/56836

Change-Id: I3fcdceff667f371fcf4b66c12bd16e2f34e6446c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391621
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-10-25 10:08:04 +00:00
Konstantin Shcheglov 9e1ac08817 Elements. Add 'ElementImpl2.reference', implement for ClassElement2.
Change-Id: Ie555b0032bba93f9c3d0dcd4cdef819eec6e1187
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391841
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-25 00:02:48 +00:00
Sam Rawlins e567b0ab52 analyzer: use typed data in RuleConfig to store enablement
Instead of using a Map of args, with a String key, `'enabled`', just
use a bool field.

Also document the fields on RuleConfig.

Also delete a test that verifies support for bool-like String YAML
keys, like `'true'`. We can just support bool keys.

Change-Id: I5bf3ab32c7e1c9ee683b977e44be88feb06ccb88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391683
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-24 16:19:31 +00:00
Johnni Winther 4b2b07bf20 [_fe_analyzer_shared] Test late resolution of macro metadata
This delays the resolution of the identifier in metadata, such the
parsed annotation expression is initially unresolved and
`Expression.resolve` must be called in order to resolve it.

This execises the support for references to identifiers declare via
macros, which will initially occur as unresolved identifiers.

Change-Id: I4863ce950ded0b9d2c1744421d9751cddea6e80c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391641
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-10-24 09:40:25 +00:00
Sam Rawlins 03d7cc4ed6 analyzer: Remove internal LintConfig class; static elements can be top-level.
This just simplifies the internal parsing code that parses out lint rule
configurations from YAML.

Change-Id: I7eb83835cff25f99b79dad9446db5215dce126fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391700
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-23 21:23:50 +00:00
Konstantin Shcheglov 535bda9cd8 Elements. Change the return type of 'name3' implementations to nullable, update some bodies.
In particular, MethodElementImpl2, which can have a fragment without a
name, and can have a name without an actual fragment (when the fragment
is synthetic).

Change-Id: Ib3383867e4351e9a11ef39ce12bf5670a4db9ee2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391701
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-23 20:14:28 +00:00
Danny Tuppeny f11bd03a99 [analyzer] Update ElementLocator2 to handle both local + top level functions
I previously fixed this for variables, but functions are the same and can have elements but no fragments too.

Change-Id: Ia1349cd1aca058da1155d7c867b5dc4384e3050f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391603
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-23 18:53:39 +00:00
Konstantin Shcheglov 3af9430ebf Elements. Separate Element2.name from Element.name by renaming to 'name3'.
They were intersecting at ElementImpl and Member(s).

This will unblock updating implementations to make them nullable.

Change-Id: Ic9907eaa0ef08c096839f212668fa1e3d92bbf3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391540
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-23 15:53:40 +00:00
Johnni Winther 35db90aef6 [cfe][analyzer] Add metadata parser
This adds a shared metadata parser to be used for macros. The parser
create a new AST which supports unresolved ASTs and delayed AST resolution.
An id-test is added for the generated AST from both CFE and analyzer.

Change-Id: Ie51817493fa6e668727a7af3a55cd22e2be722b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-10-23 07:48:15 +00:00
Chloe Stefantsova d75fe77231 [anlyzer][cfe] Use bounds to restrict choices during inference
Closes https://github.com/dart-lang/language/issues/1194

Change-Id: I6866b6ab6f29cddbb293122e09588f705aaea1c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387020
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-10-23 07:35:37 +00:00
Danny Tuppeny bff7817901 [analyzer] Update ElementLocator2 to handle both local + top level variables
Change-Id: I3f84a381c4c103d478e74a28d7ebbe85ee46606c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391441
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-23 01:02:14 +00:00
Paul Berry 88ae929cf8 Analyzer: resolve type to bound in FunctionExpressionInvocationResolver.
Consider the following code:

    void f<T extends void Function(int)>(List<T> x) {
      x.first(0);
    }

While analyzing the expression `x.first(0)`, the analyzer has to do two things:

- Convert the AST representation from a MethodInvocation (which is
  what was initially parsed) to a FunctionExpressionInvocation
  targeting a PrefixedIdentifier. This reflects the fact that the
  invocation isn't a method invocation after all; it's a function call
  invocation applied to a property get.

- Convert the static type of `x.first` from `T` to its bound, `void
  Function(int)`, in order to type check the invocation. This is done
  using the `TypeSystemImpl.resolveToBound` method.

Previously, `TypeSystemImpl.resolveToBound` was called as part of
converting the AST representation, and the resolved bound (`void
Function(int)` in this example) was stored as the static type of the
FunctionExpressionInvocation target. This led to some minor
inaccuracies in the AST representation (since the type returned by
`TypeSystemImpl.resolveToBound` is *not* the correct type of the
FunctionExpressionInvocation target).

With this change, the call to `TypeSystemImpl.resolveToBound` happens
during resolution of the FunctionExpressionInvocation instead,
allowing the target of the FunctionExpressionInvocation to retain its
correct static type.

I'm in the middle of a larger arc of work trying to introduce a new,
simpler mechanism for flow analysis to be told about the static types
of property gets, and part of that arc of work will involve
introducing a temporary check to verify that the old and new
mechanisms see the same static types. Fixing this incorrect type will
allow the temporary check to pass.

This change also has the side effect of fixing
https://github.com/dart-lang/sdk/issues/56907 (Analyzer fails to
propery type check invocations of complex expressions whose type is a
type parameter). This bug was happening in circumstances where a
FunctionExpressionInvocation arises directly from parsing (rather than
being created from a MethodInvocation), and the static type of the
target is a type variable. Previously, the analyzer was failing to
convert the static type to its bound when analyzing the
FunctionExpressionInvocation, so it was failing to type check the
invocation. Moving the call to `TypeSystemImpl.resolveToBound` into
FunctionExpressionInvocation resolution ensures that the type is
properly resolved to its bound in _all_ circumstances where a
FunctionExpressionInvocation occurs.

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

Bug: https://github.com/dart-lang/sdk/issues/56907
Change-Id: Id648d5289a6cabe95b8410abd19898acb97fc5e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390661
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-23 00:31:11 +00:00
Danny Tuppeny 9a67968189 [analyzer] Simplify documentationCommentOrNull and metadataOrEmpty
Change-Id: I8b903292b635714d9a7f52e7a212c6354ae6a8c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391404
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-22 22:40:29 +00:00
Danny Tuppeny ef04f5d880 [analyzer] Update Name.forSetter to only add trailing = if not already there
Change-Id: Id6d98a9a2902539635d2cb5acd23d3ddd4832d5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391442
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-22 22:28:09 +00:00
Kallen Tu 47d550277d [flow] Issue 1721 - Allow better promotions for final variables.
Promotions should happen for final variables because they are assigned and won't be re-assigned by the time they're evaluated. In a conservative join, promotions should not be cancelled for final variables.

Language tests made in https://dart-review.googlesource.com/c/sdk/+/390340.

Bug: https://github.com/dart-lang/language/issues/1721
Change-Id: I7bb577a694ddb5572a28884de70bd8c5b68e3c25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390803
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2024-10-22 20:05:50 +00:00
Sam Rawlins 2fd0b1aac4 linter: extract ruleConfigs earlier
Each call site for `parseLintRuleConfigs`, `processAnalysisOptionsFile`
immediately just want the `ruleConfigs` (which is the only property of a
LintConfig). So instead of passing around LintConfigs, just pass around
the list of RuleConfigs.

(LintConfig can probably be deleted now, but I'll look at that for a
separate change; might need care with google3.)

Change-Id: I30eba648e5f53bc5d5196ce95c09c8261535a737
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391161
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-21 23:32:22 +00:00
Konstantin Shcheglov cf1f2e53a3 Breaking changes for analyzer version 7.0.0
Change-Id: Id6e329c7665d1dca1920d744dd7d0e9722da768c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311461
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-21 21:32:28 +00:00
Danny Tuppeny 1a9082c558 [analyzer] Add ElementLocator2, an Element2 version of ElementLocator
Change-Id: I47fb85791ef9a077ac2d46b67d39adb9e75e45cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-21 20:40:31 +00:00
Konstantin Shcheglov e9d03a04d6 Elements. Update FindElement2 to work with elements, not fragments.
Related to: https://dart-review.googlesource.com/c/sdk/+/390812

No more `Fragment.name2` uses in `FindElement2`.

Change-Id: Idb5e766f4ced1b63bb2154d6fb1bdf5582011d73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390633
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-21 19:44:53 +00:00
Sam Rawlins 3518e02573 analyzer: Make strict modes part of AnalysisOptions API
I think when I was adding these modes, I put them on AnalysisOptionsImpl
to keep them secret and flexible. But they're pretty stable now.

Also split out the analysis options `include` tests to test merging
of individual lists and maps.

Change-Id: Ie54a1951dc82900c1fdfc06023cfa7cfb2f410a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391020
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-21 15:48:05 +00:00
Konstantin Shcheglov aff1786ee5 Elements. Issue 56917. Fix for thisOrAncestorOfType2() for InstanceElement2.
Bug: https://github.com/dart-lang/sdk/issues/56917
Change-Id: Ideda3596a7503ff98154e27353d1337b2055df02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390811
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-18 22:31:42 +00:00
Brian Wilkerson 2c960d5d4f Add access to FindElement2 in the test framework
Change-Id: I8a0def9df469a8e629e67e5c8cbd343bd076f74e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390925
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-18 20:00:40 +00:00
Sam Rawlins 4232c45c65 linter: Remove dead linter options: include and exclude
The options validator reports if you ever use `include` or `exclude` as a key
under `linter`, so these are dead and unused options.

Change-Id: I5883e05753f3c6e3f4370c070343d8f31655fd5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390808
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-18 19:50:03 +00:00