Commit Graph

13365 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
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 4e2569294e Fine. Rename recording methods in RequirementsManifest.
Change-Id: I3402e9b641978cd3004cc5d2be4b8b303fddf8a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430541
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-22 14:55:02 -07:00
Sam Rawlins ef300f558c analyzer: allow LintCode instances to set their own severity
Work towards https://github.com/dart-lang/sdk/issues/53402

Letting plugin authors set the default severity of a lint code is a
top request. Users can still customize severities with analysis
options.

Change-Id: Id0a360f4a96ca9627f00d63d3487bfde554b74e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-22 12:51:30 -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
Sam Rawlins e4810025ad Remove RuleState type hierarchy with an enum and condensed constructors
Change-Id: I07ee606b00467b8113f1722dba21b8c16cfe85b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429900
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-22 09:53:18 -07:00
Daco Harkes 7397c1e1aa [ffi/anayzer] Docs error messages
Change-Id: I790ebffb2f2b868fcea85703e25cbe7a48bea2cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430181
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-22 09:09:49 -07:00
Sam Rawlins 7a4c651eb3 analyzer: Rename 'errorCode' parameters in ErrorReporter
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I4a3d320585967a4d2e8cbed430d2a67aa3f905fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430040
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-21 16:12:59 -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
Sam Rawlins 0d0cac4955 analyzer: make fields final, in pubspec lint rule code
Work towards https://github.com/dart-lang/sdk/issues/50986

Various classes have mutable fields which should be final. Some of the
fixes require using factory constructors:

* _PSDependency, _PSEnvironment, _PSGitRepo, _PSHost, _Pubspec
* _PSNode: resourceProvider can be private and non-null
* Doc comments tidied here and there

Change-Id: Ib11a059e72670c80a4172e1c688493c1067328c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429582
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-21 14:35:29 -07:00
Konstantin Shcheglov 6fe5afce10 Elements. Return List<InterfaceTypeImpl> from InterfaceElementImpl2.allSupertypes
Change-Id: I6c62a146c56ab22e3be9e777f3f968bd218ca5ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429823
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-21 14:32:12 -07:00
Konstantin Shcheglov 64baa393e5 Elements. Deprecate JoinPatternVariableElement.variables2, use 'variables' instead.
Change-Id: Ie896718aa19a5867be1a05a210ffb28a0daaa79e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429824
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-21 13:59:30 -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
Konstantin Shcheglov f9278779f7 CQ. Use more specific normalizeInterfaceType() and normalizeFunctionType().
Change-Id: I1985efbd2536ae7847050d441780e51ea74dccdb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-20 16:22:20 -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 ea03016691 Elements. Use constructors with named formal parameters in NamedTypeBuilder and FunctionTypeBuilder.
Change-Id: I9be02c1d45d86d8ce1b0ea134d892a5d0bc30b7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429463
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-19 21:32:19 -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
Konstantin Shcheglov 62d40cc8dd Elements. Separate getters and setters in implementation.
Change-Id: I3bc236c85bf8bd86bb9995253871523791d89b4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429221
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-19 08:15:11 -07:00
Brian Wilkerson 75d640458b Add hasPublishedDocs to every diagnostic code
This makes it easier for me to find diagnostics that still need to be
documented because I can search for 'hasPublishedDocs: false'. It's
hard to search for places where it isn't specified.

In case you're interested, we currently have documentation for 70% of
the diagnostics represented in this file.

In almost every case the value is `false`, but there are two codes whose
documentation has already been published but which were not marked as
such. This means that we weren't associating a URL with the diagnostic,
but that's now been fixed.

Change-Id: I4e17671e319ec8e8887aacb6758594d7962bfc85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429202
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-18 13:38:57 -07:00
Sam Rawlins 53f21134d7 linter: add isEnabled to LinterContext directly
This was previously available as an extension on this class, but we
control the class quite directly. Seems like it should just be an API
of LinterContext.

Change-Id: I9fb61ab4471e859c39d9fa963eed2a3839fca617
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428925
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-17 06:42:54 -07:00
Sam Rawlins bc3e0ad5a8 Remove deprecated elements of AnalysisRule
* All callers are migrated off of `AbstractAnalysisRule.lintCodes`
  and `.reporter`.
* All callers are migrated off of `AnalysisRule.lintCode`.

Change-Id: I4123250c33ff1d0a488bd4457cfe5fc13160e829
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429121
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-16 20:17:16 -07:00
Sam Rawlins ac26e94fff linter: remove unused State.getDescription
Change-Id: Ia241ed01ad81cfdc399cf3011e3b4f6d43113950
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428926
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-16 17:32:00 -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 93504c7e00 CodeGen. Support for DoNotGenerate.
Change-Id: I899322ce78ea68de27b6dc6e1bcfeb92fb925657
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428904
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-16 13:35:06 -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
Paul Berry b700e36974 [analyzer] Don't panic if dart:core removed but not dart:async.
In VSCode, when the user hovers over a reference to `dart:core`
(e.g. an instance of a core type such as `String`), this triggers
VSCode to briefly open, and then close, one of the core files defining
the SDK; this in turn causes it to send notifications to the analysis
server to create and then destroy an overlay for the core SDK file.

This leads to a somewhat rare race condition: if the analyzer pumps
its event queue between receiving the notifications to create and
destroy the overlay, and there isn't adequate time in between these
two events for all active analysis drivers to re-build their library
readers, then what will happen is that
`LinkedElementFactory.removeLibraries` will get passed a `uriSet` that
contains `dart:core` but not `dart:async`. (The reason is because the
driver hasn't yet rebuilt the library cycles, so it doesn't know that
`dart:core` and `dart:async` are in the same cycle).

Before this change, `LinkedElementFactory.removeLibraries` contained a
safety check that would throw an exception if the `uriSet` ever
contained `dart:core` but not `dart:async`. Due to the race condition,
this safety check would occasionally fire, crashing the analyzer. (On
my machine, the crash would occur about once per day on average).

This safety check was incorrect (since it checked for a condition that
was thought never to occur, but in fact does occur). Also, it was not
necessary; since the only way for the race condition to occur is if
the driver hasn't yet rebuilt its library cycles, there is no harm in
removing just `dart:core` and not `dart:async`, as both have
previously been removed. And, indeed, the incorrect safety check has
always been followed by a (correct) safety check making sure that if
`dart:core` is ever removed, then after the removal, the set of
library readers is empty.

For the last month, I've been running a local build of the analyzer
with the incorrect safety check removed, and I haven't observed any
crashes.

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

Bug: https://github.com/dart-lang/sdk/issues/48051
Change-Id: I611269ea7596cc63af5eb77d5baf641454a9d315
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428902
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-05-16 10:32:30 -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 146f362c68 CodeGen. Generate AST resolveExpression()
Change-Id: Idc36c6c5b3b1b0791ab76b1b8bccb4da3bd74bb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428920
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-16 10:20:59 -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