Commit Graph

10627 Commits

Author SHA1 Message Date
Konstantin Shcheglov 19e911349f Fine. Fix for requirements on instance/interface elements with missing names.
Change-Id: Ide320ccc1bd146aba60a0d2bced405fc2612a027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-23 10:28:24 -07:00
Konstantin Shcheglov d5e914ad09 Elements. Fix InstanceElementImpl2.name3, return firstFragment.name2, nullable.
Change-Id: Idd7239c1be692219f1f1ba735f475fe0141c0c6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430821
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-23 10:20:20 -07:00
Sam Rawlins 823b6668f6 analyzer: Rename ErrorSeverityTest to DiagnosticSeverityTest
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I1361a28834cb95a8b7ad9f131132b7b77e888483
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430547
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-23 10:14:14 -07:00
Kallen Tu 448c8aed6a [analyzer] Dot shorthands: Additional unit test for AMBIGUOUS_IMPORT.
Added a small unit test to make sure AMBIGUOUS_IMPORT with dot shorthands still produces the expected errors.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: Ife115bfb1fd34f396c5b3d00cb4f4d75e933e963
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430562
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-23 09:32:50 -07:00
Konstantin Shcheglov 88e2419b0f Elements. Convert FunctionTypeImpl.parameters to List<FormalParameterElementMixin>.
Change-Id: Idfba32254b458c68f75618d276b824ad734e13ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430601
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-23 08:15:11 -07:00
Sam Rawlins 2dc94ee84a analyzer: Rename DiagnosticCode.errorSeverity to DiagnosticCode.severity
Change-Id: I244a96a940f82902a20e817fd13fe32026607ce3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430581
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-22 17:25:01 -07:00
Konstantin Shcheglov b37171cf10 Fine. Support for type aliases.
Change-Id: I7907ba6b4041bd3723d37a652b883cea6dfc617f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430540
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-22 12:50:21 -07:00
Konstantin Shcheglov 24ebc7a125 Fine. Support for extensions.
Change-Id: I3ebae3c6228b1b2c95e224e2e6624e46212d3b2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430461
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-22 11:36:34 -07:00
Sam Rawlins 612c9f6834 analyzer: rename AnalysisRule 'errorCode' parameters
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: I3d5a55f6638b18e2941a574a71c89fc142f0c206
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430060
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-22 11:27:21 -07:00
Konstantin Shcheglov f637435eb6 Fine. Support for extension types.
Change-Id: I82bcaafd877b1192806343ea46e2c6a5594f131a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430520
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-22 11:14:23 -07:00
Sam Rawlins f2d416b866 analyzer: simplify PackageConfigFileBuilder.toContent
This API did not exist (was not public) in analyzer 7.4.x, so is safe
to change in 8.0.0.

Change-Id: Ib4a06008b1cdf1be4f33dcb9036ea87b6d258067
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430041
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-22 10:58:49 -07:00
Konstantin Shcheglov 058641a563 Fine. Support for TypeLiteral.
Change-Id: I2ee92b0be99cbeea39cbd9d07166e073fc230846
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430322
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-22 10:14:35 -07:00
Sam Rawlins 87f5185577 analyzer: Rename NodeLintRegistry to RuleVisitorRegistry, provide alias
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: Id0053b4721ca0517e315d5118ae48839dfaa3027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429465
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-22 10:03:19 -07:00
Konstantin Shcheglov efa2870f43 Fine. Fix for checking requirements of re-exports.
Change-Id: I1a2e8302e5534fe8d77d3f8d7964d0626835e727
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430124
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-21 14:48:40 -07:00
Konstantin Shcheglov 9482f95363 Fine. Fill interfaces of supertypes before subtypes.
So, that we can find synthetic top-merged members.

Change-Id: Ic8e90fe5c3a8ee44730f9c3acde0a7618bcca563
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429821
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-05-21 09:34:39 -07:00
Kallen Tu ded5f0bce2 [analyzer] Dot shorthands: Report error for using enum constructor.
Added an additional error check for `CompileTimeErrorCode.INVALID_REFERENCE_TO_GENERATIVE_ENUM_CONSTRUCTOR`. Refactored the helper slightly to allow dot shorthand constructor invocations to be able to use it.

Added a unit test.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I4eee2a3464913cdba0e213aa47a29faad2141937
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428222
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-21 08:04:16 -07:00
Konstantin Shcheglov 2565d073af Fine. Include 'kind' into ManifestElement, print it.
As noted in https://dart-review.googlesource.com/c/sdk/+/429540,
without it the output was somewhat confusing.

Change-Id: I18e263718fde482367af496e11e133937a946435
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429681
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-05-21 07:27:35 -07:00
Daco Harkes 8ac2279b07 [native assets] Graduate to preview
This PR enables native assets on the main and dev channel by default,
and make native assets available on the beta channel.

This PR removes the flag from invocations.

The helper packages (`package:hooks` and `package:code_assets`) will
stay 0.x for now, until the SDK constraint can be bumped to a beta
release and we're happy with the Dart API.

`dart build` is also made available as preview (without a flag on
the main, dev, and beta channels). We're still finalizing the spec for
this command. (https://github.com/dart-lang/sdk/issues/60730)

`dart test` will need https://github.com/dart-lang/test/pull/2501.
This means users will need to update their `package:test` dependency.

This PR refactors the way that invalid `package_config.json`s are
handled: they are now loaded in the dartdev commands and handled there.

Bug: https://github.com/dart-lang/sdk/issues/50565
Project: https://github.com/orgs/dart-lang/projects/99/

Change-Id: I7db9ff6d7196750cab9379a4605c6bbf89a974d7
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-win-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429920
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-05-21 06:10:19 -07:00
Johnni Winther ed2f893826 [analyzer] Handle display for type parameters without name
The ElementDisplayStringBuilder crash when encountering a type parameter
without a name. This chance handles the case by using the empty string as
the name in the computation of unique type parameters.

Fixes b/418755155

Change-Id: I4fd1a6df64a31614e0c4548963d0c5507cc94ca8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429640
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-21 00:22:01 -07:00
Sam Rawlins 4ef189a513 linter: Rename State to RuleState, and sub-classes
Change-Id: Id74c1a34e0a3154e1720d323bf4002aceb092dd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429160
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-20 15:52:54 -07:00
Konstantin Shcheglov 5d175fa43c Elements. Deprecate InterfaceElement.constructors2, use constructors.
Change-Id: I78faea1fdbc55e46cdb7fc0b187d12561736cec2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429822
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-20 15:11:42 -07:00
Sam Rawlins 3a08da01af analyzer: Support comment references of members of aliased type
Work towards https://github.com/dart-lang/sdk/issues/56109
(specifically support for
https://github.com/dart-lang/sdk/issues/56109#issuecomment-2292355457).

Currently, instance (and static) members of a type can be referenced in
a comment reference. This change adds support to referencing instance
(and static) members of a type via a type alias.

Change-Id: Ic789a0185cb8c56236346ef3ae658481fbd4cd70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429226
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-20 11:35:29 -07:00
Konstantin Shcheglov 89e9afcb73 Fine. Support for enums.
Change-Id: I56d7a40e2d140c8e25e9050e54c0ecc36307ea73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425880
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-19 21:38:44 -07:00
Konstantin Shcheglov 8f9f6f6360 Fine. Remove 'constInitializer' from 'TopLevelGetterItem', depend on both getter and variable.
Note that now getters don't change, because they don't depend on the
constant initializers, but fields and top-level variables do.

Change-Id: I35ae905b4f8d1f39dfeff91f7add8324ef3a3c7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429540
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-19 21:30:39 -07:00
Konstantin Shcheglov 16cb3bad6d Fine. Add LibraryManifest.declaredVariables
Change-Id: Ifd23ee6f4ad9500b89c3e50bec5064b5a64cbac1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429425
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-19 21:14:09 -07:00
Konstantin Shcheglov 13377d11d8 Fine. Use separate top-level declaredClasses, etc.
Change-Id: Id7a675f7c641acb1839aa26c65099eeffff7a955
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429462
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-19 20:43:34 -07:00
Sam Rawlins 540efbbb5d analyzer: Extract some public API from WorkspacePackage
Fixes https://github.com/dart-lang/sdk/issues/60725

Change-Id: I63e79075d6538810ddc518e96b5bb7430e55496b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428564
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-19 16:24:19 -07:00
Alexander Aprelev 1159405ad4 Revert "[DAS] Trigger incompatible lint for included rules"
This reverts commit 261f8199af 

Reason for revert: it breaks flutter customer testing on hh and on the roller.


Original change's description:
> [DAS] Trigger incompatible lint for included rules
>
> Fixes: https://github.com/dart-lang/sdk/issues/60125
> Change-Id: Icc0b8efda0e7e915d7315a1c2e70c1a7a5093057
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419982
> Auto-Submit: Felipe Morschel <git@fmorschel.dev>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

Change-Id: I0db90864092760efde1cb02cc792c1de14eabf2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429381
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2025-05-19 10:08:35 -07:00
Sam Rawlins e35e665259 analyzer_testing: convert all modifyFile users to modifyFile2
This also involves tidying up blaze_watcher_test, in order to
easily get back a File object from a helper method.

Change-Id: If9dc812dc3a97a205dee600b89c3e8490e9efcba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429201
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-19 07:11:23 -07:00
FMorschel 261f8199af [DAS] Trigger incompatible lint for included rules
Fixes: https://github.com/dart-lang/sdk/issues/60125
Change-Id: Icc0b8efda0e7e915d7315a1c2e70c1a7a5093057
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419982
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-16 17:31:21 -07:00
Konstantin Shcheglov eb823d7e56 Fine. Separate requestedXyz in test expectations.
This was initially in https://dart-review.googlesource.com/c/sdk/+/428562,
but partially reverted to ease review of test expectations.

Change-Id: Ib13936042b7a24a33aec22846b1d01999016481a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429120
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-16 13:29:49 -07:00
Konstantin Shcheglov ca885680aa Elements. Update a few remained enclosingElement2 name references.
After: https://dart-review.googlesource.com/c/sdk/+/428860
Change-Id: I7183e3fcdf36241a183a0d2a988db86fe091f2ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428922
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-16 13:27:03 -07:00
Konstantin Shcheglov adb4a8a559 Elements. Deprecate InstanceFragment.xyz2, use 'xyz' instead.
Change-Id: I18331cc6a2cd0c9f01de79d8d5ea0178cd39dc16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428881
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-16 10:29:02 -07:00
Konstantin Shcheglov 78bc6da66c Elements. Deprecate InstanceElement.xyz2, use 'xyz' instead.
Change-Id: Ie12b7596b70c77fd2f08520a423eeaf3b6978326
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-16 10:24:25 -07:00
Konstantin Shcheglov 07fe6950bb Elements. LibraryElementImpl extends ElementImpl2, not FragmentImpl.
Change-Id: Ibdadbd13238551b8ec70061bc0c24615831b1973
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427305
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-16 10:12:42 -07:00
Jens Johansen 88db201efc [analyzer] Replace pathContext.relative inside LocatedGlob.matches
Comparing a before and an after aot-compiled analysis server,
running each 25 times, via `pkg/front_end/tool/benchmarker.dart`:

```
out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart \
  --iterations=25 \
  --snapshot=pkg/analysis_server/bin/server.aot.1 \
  --snapshot=pkg/analysis_server/bin/server.aot.2 \
  --arguments="--disable-file-byte-store" \
  --arguments="--train-using" \
  --arguments="pkg/front_end/lib/"
```

(where `server.aot.1` is an aot-compile without this CL and
`server.aot.2` is an aot-compile with this CL) gets this result:

```
msec task-clock:u: -5.2977% +/- 0.4313% (-466.26 +/- 37.96) (8801.11 -> 8334.86)
page-faults:u: -2.5748% +/- 0.1648% (-4094.76 +/- 262.07) (159032.16 -> 154937.40)
cycles:u: -5.5212% +/- 0.4440% (-2034156211.44 +/- 163567376.21) (36842412971.36 -> 34808256759.92)
instructions:u: -8.2456% +/- 0.0556% (-4125031082.64 +/- 27819990.07) (50026884750.04 -> 45901853667.40)
branch-misses:u: -4.2637% +/- 2.0984% (-5839704.08 +/- 2873998.26) (136961902.80 -> 131122198.72)
seconds time elapsed: -5.2895% +/- 0.4311% (-0.47 +/- 0.04) (8.82 -> 8.35)
seconds user: -5.5473% +/- 0.5002% (-0.47 +/- 0.04) (8.46 -> 7.99)
Scavenge(   new space) goes from 152 to 134
MarkSweep(   promotion) goes from 15 to 14
Notice combined GC time goes from 2804 ms to 2707 ms (notice only 1 run each).
```
Change-Id: Ib5070b3c037b30f96bb91b3536d85b85ebe0c30c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427442
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-16 01:28:25 -07:00
Konstantin Shcheglov 72b0d2d2af Fine. Use separate declaredXyz in InstanceItem.
This simplifies the implementation, even if makes it less cool.

Change-Id: I9418f959ca36455a1fff59cd4f980b319351d987
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428562
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-15 19:26:43 -07:00
Konstantin Shcheglov 69cb105a5f Fine. Write separate declaredXyz in tests.
Change-Id: I6d87df7e19fde64063734aadf56456878d61353c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428842
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-15 18:28:49 -07:00
Konstantin Shcheglov 2db49488c1 CodeGen. Generate members of most leaf AstNodeImpl classes.
Every declaration annotated with `@generated` was generated. In the
current version there are `2180` such declarations. For comparison,
there are `2167` instances of `@override` in total, and `@generated +
@override` has `1576` instances, so we generate `72%` of all overrides.

The generator automatically formats and sorts `ast.dart` after applying
changes, so the result is nice and clean. We run a separate DAS instance
from the script to do this.

Things to improve in the future:

1. Generate for non-leaf classes.

2. Support for `DoNotGenerate`.

Change-Id: I05e6356c9aac68449d5117ad8fd533735f130c73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427481
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-15 18:05:42 -07:00
Sam Rawlins bd700772ff analyzer: move testing utilities to analyzer_testing package
Work towards https://github.com/dart-lang/sdk/issues/55660

Change-Id: Iae062d95e5cf3b94b540496242b3627268ac2612
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428844
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-15 16:28:50 -07:00
Sam Rawlins 22453ba77f linter: deprecate AnalysisRule.lintCode
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: Iedf1127b9f04aec910647c7f35597f38c6bfe1d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428846
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-15 16:20:11 -07:00
Konstantin Shcheglov 05da3e1f22 Elements. Deprecate Element.enclosingElement2, use enclosingElement.
Change-Id: I055b1f9dd1c00605d813effcbbadb9cea874129a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-15 13:47:32 -07:00
Kallen Tu f849516bd0 [analyzer] Dot shorthands: Avoid crashing with prefix and postfix operators.
When we evaluate the `target` for this `IndexExpression`, we don't cache the  dot shorthand context which causes the analyzer to crash. Added a context push of the `target` (whose context is `UnknownType`) which allows the analyzer to error out without crashing.

Passing co19 tests and unit tests.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I6a19b3e92ed803a51d0cfd320df886a26a36b33d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426289
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-15 11:47:17 -07:00
Sam Rawlins 701c6113c2 analyzer: Simplify interface of WorkspacePackage, use File for root
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: I56c14bc941e1204b9d9cc13086f5ed92a1228585
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428623
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-15 11:35:42 -07:00
Sam Rawlins a3b1b4f172 analyzer: Deprecate AbstractAnalysisRule.lintCodes
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: I4c86dbf806964c98f4a1c5854eb53c6c8cfe002b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428624
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-15 11:04:43 -07:00
Sam Rawlins 0d1fe0fc3a analyzer: Remove unnecessary InheritanceManager3 from LinterContext
Work towards https://github.com/dart-lang/sdk/issues/50986

At the same time, migrate `redeclare_verifier` from InheritanceManager3,
so that the impl is the same as the `annotate_redeclares` lint rule.

Change-Id: I9c5c77dcf50aa54820473874327bc3a7b93fd987
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428380
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-13 15:21:52 -07:00
Konstantin Shcheglov 3117e4062a Fine. Record requested fields.
Directly with `getField`, or indirectly via getter/setter.

Many `test_dependency_` switched to `instanceFieldIdMismatch` because
almost any use of a getter / setter in code like `x.foo` end up
requesting the field while resolving.

Change-Id: I5e7d68c6e8a055e60e8d5feeee838df3f6c5b1d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428301
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-13 12:47:10 -07:00
Kallen Tu 917e519ce7 [analyzer] Dot shorthands: Check for required parameters in invocations.
Added an additional check in the analyzer to make sure required parameters are given.

Unit test added.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I887a46294c961136bd0a1a3999978fe2db99b315
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428221
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-13 10:24:37 -07:00
Kallen Tu ecc6b93abd [cfe/analyzer] Dot shorthands: Abstract constructors can't be instantiated or torn off.
Adding a few errors on when we instantiate or tear off abstract constructors. Should be parallel to how we currently check for these errors in the CFE and analyzer.

Follow up to https://dart-review.googlesource.com/c/sdk/+/426682

Language test added, co19 test passing, and unit tests added.

Bug: https://github.com/dart-lang/sdk/issues/59758, https://github.com/dart-lang/sdk/issues/59835
Change-Id: I9b34e5f960856ce50aa969ca27e56907ae3a2a8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428201
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-13 10:10:51 -07:00
Kallen Tu c0d1583d60 [analyzer] Dot shorthands: Report error when instantiating abstract class.
This CL reports `INSTANTIATE_ABSTRACT_CLASS` when we are trying to instantiate an abstract class (with a non-factory constructor).

co19 tests and unit tests passing.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I5eded14f558d528265d82fd63cc0af3d9b052eac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426682
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-12 11:37:28 -07:00