Commit Graph

468 Commits

Author SHA1 Message Date
Sam Rawlins 43e01310a4 analyzer_testing: Rename PubPackageResolutionTest.ignoredErrorCodes to ignoredDiagnosticCodes
Change-Id: I0a951ecbf8aa74d1c00df99e0f5bdab84bb00dde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430542
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-23 10:12:18 -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
Sam Rawlins 9d2df84973 analyzer_testing: add more default-ignored codes
UNUSED_ELEMENT and UNUSED_FIELD were added to the "ignore list" for
the tests of a dozen lint rules. I think it is pretty harmless to ignore
them by default, and save plugin authors some `// ignore:` comments, or
hand-wringing about how to get rid of an "unused" field in a test which
is needed in order to test an analysis rule.

Change-Id: Ic35fead8a44d8d3341f9e32e92b53610b517edf5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430121
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-05-22 09:23:50 -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
Sam Rawlins f81079035f analyzer_testing: Move LintRuleTest and linter's PubPackageResolutionTest
Most of the behavior of LintRuleTest is extracted into a public class
in analyzer_testing, AnalysisRuleTest. A little bit of code is left in
LintRuleTest, so that first-party lint rules can be tested by
registering the first-party lint rules. And those lint rules can
declare the `lintRule` that each is concerned with, rather than the
new `analysisRule` getter.

PubPackageResolutionTest is left as private impl, because I think it
may undergo some changes, and we may be merging more shared code, and
the name may change. A few first-party lint rules have tests that
refer to this class, which is OK.

Other than that, no code or behavior changes are in this CL.

Work towards https://github.com/dart-lang/sdk/issues/55660

Change-Id: I447850c438af7d0fe90889d2eaec6f2f8b4f8281
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-20 10:25:50 -07:00
Sam Rawlins 0e5f60e80a linter: enforce unnecessary_async
Change-Id: If5d025ccf2d1a6d80256579bee7a7b3a4d039dde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429061
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-17 07:21:41 -07:00
FMorschel 83eb816e51 [linter] Adds new switch_on_type lint
Fixes: https://github.com/dart-lang/sdk/issues/59546
Change-Id: Ib78714e03c1487376c961214910d10c24ec9f8ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-05-16 16:00:54 -07:00
Sam Rawlins dfaf1514ea linter: discarded_futures: do not report on await-in-synchronous function
When a synchronous function body has an `await` expression, we report
an error. We don't need to _also_ report a lint.

The noted error, `CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT`, already
is associated with the "add async" fix. Reporting a lint when an error
is also definitely reported is just double reporting.

Change-Id: If6d260a01cc654c87897480996d3f6f4b61373dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429063
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-16 15:34:20 -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
Sam Rawlins 0da88371bb linter: remove DriverBasedAnalysisContext to use less private API
Change-Id: I5fb7686539c3a7db39c1fc027868c927e1d5d676
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428342
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-15 11:47:44 -07:00
Sam Rawlins d67a7d879e linter: Remove unused ast utilities
Change-Id: I4a436a77a69cc4a78ceb1ca27b95a81ab55dc868
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428422
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-05-14 09:04:01 -07:00
Sam Rawlins 06d2071504 linter: Remove an export before it becomes cross-package
Work towards https://github.com/dart-lang/sdk/issues/55660

Change-Id: I5ffe612695be725e0af0497f9b2917da3d52ec7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428420
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-14 07:12:19 -07:00
Sam Rawlins da58ca0060 analyzer: Convert getPubspecVisitor to a getter named pubspecVisitor
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: I1bcdc6b32efef0f7e70bbb49c3cce046f95351fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428225
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-13 09:01:59 -07:00
Sam Rawlins 27e819f4cc linter: combine test classes into one
Work towards https://github.com/dart-lang/sdk/issues/55660

The only direct subclass of `_ContextResolutionTest` is
`PubPackageResolutionTest`, so they can be combined. I keep all of the
API the same, with a few exceptions:

* Make `addTestFile`, `testFilePath`, `resolveTestFile` private. They
  were very lightly used outside of `rule_test_support.dart`, in
  exceptional situations, where they can be replaced with local members.
* This allows for a much more idiomatic impl for `file_names_test.dart`.

Change-Id: Icfa63ca488c4722067fc7d471343afd398a9dddc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428161
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-12 16:50:59 -07:00
Sam Rawlins aebc7fd74c analyzer: Tidy up Spelunker API
Work towards https://github.com/dart-lang/sdk/issues/55660

Spelunker will move to the analyzer_testing package, so we must first
clean it up.

Spelunker had two subclasses, but their only differentiation was the
calculation of a getter, which could be a final field. So I remove the
subclasses, move the "File"-based one to the spelunk utility script,
and change the Spelunker constructor to take in a source string.
Additionally:

* Make all of the fields private.
* Remove isDartFileName and isPubspecFileName. These calculations can
  be inlined into their call sites and make use of the `file_paths`
  library.

Change-Id: I4b97ed03a2845440dabd3a9ab0aa3b3ba4af5959
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428083
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-12 14:10:20 -07:00
Sam Rawlins c4c9854b9b analyzer_testing: Move ResourceProviderMixin to analyzer_testing
Work towards https://github.com/dart-lang/sdk/issues/55660

Change-Id: I31932409e495369793dd16c017385c98b86cf44c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427480
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-09 16:56:29 -07:00
Paul Berry a757d2af41 Enable sound-flow-analysis for Dart 3.9.
Bug: https://github.com/dart-lang/sdk/issues/60438
Change-Id: I908d4e4a9143142281d8198870f40eba6cf6f67f
Tested: trybots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427500
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-09 14:50:26 -07:00
Sam Rawlins f2d4ca7968 linter: unawaited_futures: catch Future subtypes
Change-Id: Iabdfc1ec4984d6717cc3d85729b577fb2385e749
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-09 11:04:36 -07:00
Sam Rawlins 3021cc4913 analyzer: Move PackageConfigFileBuilder to public API.
Work towards https://github.com/dart-lang/sdk/issues/55660

Change-Id: I3df2cd374f6b3ef9e027f0e07c748be6ea21ebb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427586
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-09 10:57:55 -07:00
Sam Rawlins abd4e7754c Introduce two subclasses of 'LintRule' for handling multiple lint codes
Before this change, we had an enforcement that either 'get lintCode' or
'get lintCodes' is implemented, but it was a runtime enforcement. And it
was a little roundabout.

The new system is simpler and more typical:
* `AbstractLintRule` is the parent type, and it's sealed. It provides
  `get lintCodes` as an interface. Code outside of the lint rules
  requires this getter, in registering codes, etc.
* `LintRule` is the new subclass which is the "90% case." It declares
  a `get lintRule`, and offers simpler reporting methods for reporting
  a single code everywhere.
* `MultiLintRule` is the new subclass which represents that last
  "10% case." It only declares the reporting methods which all require
  a LintCode parameter, since there is no concept of a "default lint
  code among all my lint codes."

Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: I63cbbfc1d936bb4428aa0b8f5fb0638c9b61b3dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426284
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-08 16:10:57 -07:00
Sam Rawlins f9c5944a33 linter: public_member_api_docs: dont report internal top-level variable
Fixes https://github.com/dart-lang/sdk/issues/60617

This includes a bit of clean-up of the other cases where we are concerned with
`@internal`.

Change-Id: I506725c2280ab90fd5e1014eb8478497de8a0480
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-08 07:39:53 -07:00
Sam Rawlins 2f706c4290 analyzer_testing: move experiments library to analyzer_testing
Work towards https://github.com/dart-lang/sdk/issues/55660

Change-Id: I9c5aa920e9f96f99ea00d6993b5f4dafd415f831
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426986
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-07 13:12:13 -07:00
Sam Rawlins 7431e885e8 analyzer_testing: Move in the mock packages.
Work towards https://github.com/dart-lang/sdk/issues/55660

Change-Id: Ic789b8347d3bfc71a02af423fbb1a8c58da7b32d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424921
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-06 11:32:22 -07:00
Sam Rawlins 8aa021f31e linter: Use Diagnostic instead of deprecated AnalysisError
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I225bcbe2c0033872b0349258f7f2135aab6a8d20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426561
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-05 15:44:14 -07:00
Sam Rawlins cfa4be3d93 analyzer: Use DiagnosticSeverity in analyzer packages
Work towards https://github.com/dart-lang/sdk/issues/60635

DiagnosticSeverity is the new name for ErrorSeverity.

Change-Id: I9d1040f23d4fe8affb234ff62527133e439adf50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426341
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-03 17:14:04 -07:00
Sam Rawlins b6508124a4 linter: add unnecessary_unawaited lint rule
Work towards https://github.com/dart-lang/sdk/issues/46218

Change-Id: I0c6953463d053205cc1110f554578e6b85eac0db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426240
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-02 14:36:20 -07:00
Sam Rawlins a913c61186 linter: Use new DiagnosticCode name
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I3f53e1c7db21047665e1a286673d624c2d48c834
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425684
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-01 07:47:38 -07:00
Erik Ernst 2f0cbeb485 Report type parameters whose name is a type in scope
See https://github.com/dart-lang/sdk/issues/59517 for background and discussion.

Change-Id: I6d02d07cdd95e8b2b647cf3f7f87a9f27a1c48b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381841
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-01 04:04:30 -07:00
Sam Rawlins 35e8b9ba0b analyzer: Deprecate ErrorType in favor of new name, DiagnosticType
Change-Id: I552e816de6d526e3476cac9dd3ee2919fc7ec499
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425720
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2025-04-30 19:07:42 -07:00
Sam Rawlins 992cfb13bc analyzer: Deprecate AnalysisError.correction; simplify other final fields
Work towards https://github.com/dart-lang/sdk/issues/60635

* `AnalysisError._contextMessages` unnecessarily backed the public
  `contextMessages` getter; the field is final so it can be public
  itself.
* `AnalysisError._correctionMessage` unnecessarily backed the public
  `correctionMessage` getter; the field is final so it can be public
  itself.

Change-Id: If269d4ed590ef7df81d9b9e3be03766601526d7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425620
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-04-30 16:06:19 -07:00
Sam Rawlins 1c64983086 analyzer: Add docs to ExpectedDiagnostic, LintRuleTest, and PubPackageResolutionTest
These will (likely / in some capacity) become public API.

Change-Id: Ia9af4a227956d1335ad1d748e6100d12befc40f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425582
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-30 11:48:22 -07:00
Sam Rawlins 7d1c867f42 linter: Fix await_only_futures: Fix for type variables and intersection types
Fixes https://github.com/dart-lang/sdk/issues/58492

Change-Id: Iae036742b05815332553a540c95b4fdf5ad83413
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425402
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-04-29 17:44:59 -07:00
Konstantin Shcheglov b2fdd8a345 Elements. Rename XyzElement2 into XyzElement.
The CL was done with rename + adding typedef for each class.

Change-Id: Ia25cc581d2e42cf7d12a85a3579af952d5c232ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424687
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-04-25 13:27:18 -07:00
Konstantin Shcheglov 49599e06cc Elements. Deprecated element2.dart library.
Change-Id: I2be38df49e6f242d9fe59f34164549da4a0f41b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424683
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-04-25 11:23:18 -07:00
Sam Rawlins 5828f83e57 linter: Support for inherited @awaitNotRequired annotations
Change-Id: I6c55f6423f6a44838674165ab311f31c64ffd399
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424682
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-04-25 09:20:39 -07:00
Sam Rawlins 0501720890 linter: Consider @awaitNotRequired in the discared_futures rule
Work towards https://github.com/dart-lang/sdk/issues/46218

Change-Id: I9e356ab28996351d2ebfb15f655816f35a825339
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-24 11:29:53 -07:00
Ben Konyi 85227c4492 [ Analyzer ] Add diagnostics for Flutter Widget Previews
The Flutter Widget Previewer relies on code generation to import code from
a developer's project into a generated 'widget preview scaffold' that lives
in the project's '.dart_tool' directory. The nature of this implementation
means that any symbols referenced in the declaration of the preview (e.g.,
in the invocation of the `Preview(...)` constructor or the name of the
preview function) must be publicly accessible from outside the library in
which they are defined. One of the main uses for this diagnostic is to flag
usages of private symbols within preview declarations.

These diagnostics also ensures that the `@Preview(...)` annotation can only be
applied to a functions or constructors that:

  - Are statically accessible (e.g., no instance methods)
  - Have explicit implementations (e.g., not abstract or external)

Fixes https://github.com/flutter/flutter/issues/167193

Change-Id: I208c7f18c8d4ad826fed46a0dc625d090ff186ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423860
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-04-24 11:15:59 -07:00
Sam Rawlins 41461344d5 analyzer/linter: Support an @awaitNotRequired annotation
Work towards https://github.com/dart-lang/sdk/issues/46218

This implements the bulk of the `@awaitNotRequired` support as specified here: https://github.com/dart-lang/sdk/issues/46218#issuecomment-2725895048

Remaining work:

* implement inheritence
* report a badly-placed annotation
* add the annotation to the real meta package

Change-Id: Ida16018746704d0baa165ab9be95187b52a79061
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423923
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-04-23 10:53:39 -07:00
Sam Rawlins dce95377dd analyzer etc: move pubspecYamlContent function to be shared
This function was defined once in analyzer testing code, once in
linter testing code. In this change, all three are combined into one
function in analyzer_utilities.

Change-Id: I3c9d30c814bf47bf3436ad0acaba48b75fd2c55c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423606
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-22 10:49:29 -07:00
Sam Rawlins 5eef8e4ebe analyzer etc: move analysisOptionsContent function to be shared
This function was defined once in analyzer testing code, once in
linter testing code, and once in analysis_server testing code. In this
change, all three are combined into one function in analyzer_utilities.

Change-Id: Ib2daa7b3d14aae6ca2aa09f6f9bdeaf76bc72d10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423068
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-21 13:01:36 -07:00
Konstantin Shcheglov 6faefb6db1 Elements. Remove test for analyzer_use_new_elements
It becomes a source of problems while removing V1 element model.
See https://dart-review.googlesource.com/c/sdk/+/422880

I decided to keep the implementation for now, just in case we use V1
accidentally. But we should not change it anymore, because we will not
have tests after this CL.

Change-Id: Iabdab21e12b4142c2df37876df5d7128988c5ded
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-04-17 12:48:06 -07:00
Konstantin Shcheglov 90a5e71787 Lint. unnecessary_this. Report for this.foo() of the same class.
Change-Id: I55fe9d08fd8d9985f992c7b2cda6376efb8386be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421421
Reviewed-by: Derek Xu <derekx@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-04-16 12:57:12 -07:00
Ben Konyi 5ec368622c [ Linter ] Don't mark functions annotated with @Preview() as unreachable from main
Fixes https://github.com/flutter/flutter/issues/167195

Change-Id: Ie98a0fd5c1b69771b7e9e9cb54c33bfa403381e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422520
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-04-15 14:06:09 -07:00
FMorschel 59ceb55042 [linter] Fixes unnecessary_this false negative inside if case
Fixes: https://github.com/dart-lang/sdk/issues/60514
Change-Id: I934f22461b395177eca0046b0bf8797067ccbe46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421961
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-04-11 10:22:44 -07:00
Konstantin Shcheglov 45fa7284cb Elements. Deprecate InterfaceTypeImpl.element
Change-Id: Iff7d90a8d614a6069ec7f13810c8bd6600cfcc1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418919
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-04-01 14:38:38 -07:00
Konstantin Shcheglov 0fda5de36a Elements. Deprecate ClassElement.
Change-Id: I0bf4a73bacc4917d4f61c91bcdceba41a9c18ec9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418903
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-03-31 11:09:38 -07:00
FMorschel cd54936eb8 [DAS] Fixes broken discarded futures tests
Bug: https://github.com/dart-lang/sdk/issues/59887
Change-Id: I6c8204771b70d49091f882e5b7f875b158724b89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417900
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-03-25 13:09:48 -07:00
FMorschel b855b9ada3 [DAS] Fixes discarded_futures assignment to future parameters
R=pquitslund@google.com

Bug: https://github.com/dart-lang/sdk/issues/59887

Fixes: https://github.com/dart-lang/sdk/issues/59504
Fixes: https://github.com/dart-lang/sdk/issues/58889
Fixes: https://github.com/dart-lang/sdk/issues/59455
Fixes: https://github.com/dart-lang/sdk/issues/59151
Fixes: https://github.com/dart-lang/sdk/issues/59387
Fixes: https://github.com/dart-lang/sdk/issues/59331
Fixes: https://github.com/dart-lang/sdk/issues/59949

Change-Id: I6d93a36f626650b744e2e4ec52bbefe171483820
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403901
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-03-25 09:15:22 -07:00