Commit Graph

814 Commits

Author SHA1 Message Date
Sam Rawlins c219974ecf analyzer: Deprecate Diagnostic.errorCode in favor of diagnosticCode
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I2c7d64a81bc214e64fbc3ac95cf1fe2363a6ebd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433242
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-09 09:22:22 -07:00
Brian Wilkerson 55a2089034 Add a test for hasPublishedDocs
This causes the code that parses the `messages.yaml` files in either
the analyzer or linter packages so that it throw an exception if any
code fails to have an explicit `hasPublishedDocs` key.

We decided to require the field because it makes it easier to identify
codes for which documentation has not yet been published. Prior to this
the search looked for codes missing this key _or_ codes where this key
had a value of `false`, but now only the last needs to be searched for
which can be done using a simple textual search.

Change-Id: I1aa59eb02a628fae8cb79c5390b59c787218fe15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431761
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-30 12:24:39 -07:00
Konstantin Shcheglov e724547892 Elements. Deprecate Annotatable.metadata2, use 'metadata' instead.
Change-Id: Ic4a7d8f19cb1793031951aadeb340e5dadf4744c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430261
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-30 11:09:40 -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 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 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 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 49562fd152 analyzer: Deprecate ErrorCode in favor of replacement: DiagnosticCode
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I0cfc0bff4e5d10b7cb373f77de55fffc13b8cf76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426641
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-06 14:43:10 -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 fafad4e03d analyzer: Move the API tool so that it can generate API for other packages
Also, add some scripts to generate the analyzer_testing API, and checkin
the api.txt file for analyzer_testing.

In order to avoid a private analyzer import, I add `isExperimental` and
`hasExperimental` support for `@experimental` annotation, and switch
to using public APIs in `_dumpElement`.

Change-Id: I44319270d4e6083b80973b45933268c472876232
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426282
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-02 14:22:31 -07:00
Sam Rawlins 4ef2725654 Add an analyzer_testing package
We intend to publish and maintain this as a set of testing-related
utilities for the analyzer packages and for analyzer plugins.

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

See the doc: https://docs.google.com/document/d/1jRtd8B1ijPAP6Pz89HRnyIZXw2VMjaZx0vRZTpoNO84/edit?tab=t.0#heading=h.2sz41a544qhi

Change-Id: I2764b1357a932fa955060b26d78038997eaa9536
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425080
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-02 06:58:49 -07:00
Sam Rawlins 24fbe71dd6 analyzer: Use DiagnosticCode instead of ErrorCode in tests
Change-Id: I6b70bda2e678777efdfde7c0cb9dca4ec85b27e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425686
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-01 09:18:03 -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 62824ba646 Migrate the last AnalysisOptionsHintCodes to be Warnings
Change-Id: I8f9826a57e434a185d6c0d68e2ccbd1c2610885d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425157
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-29 10:44:55 -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
Konstantin Shcheglov becd91df17 Format analyzer/ with tall mode.
Change-Id: I410cd1cf63fbf00b868bbb3e060433cad3ac9e6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423520
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-04-21 12:15:58 -07:00
Sam Rawlins 2f05f9d755 analyzer: Support type aliases in API file
Change-Id: I37114d18fb5e4cb9d6706dc1a0ee4aaf761409cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423424
Reviewed-by: Paul Berry <paulberry@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-04-19 08:13:46 -07:00
Paul Berry addc7dbe86 [analyzer] Document immediate sub-interfaces of sealed classes in api.txt.
Since it is a breaking change to add a new sub-interface of a sealed
class, it is useful to see when the set of sub-interfaces of each
sealed class in the analyzer public API changes.

This change adds information to `api.txt` documenting the complete set
of sub-interfaces of each sealed class.

Based on a suggestion from Konstantin
(https://dart-review.googlesource.com/c/sdk/+/420843/comment/5a1fe050_91c066d1/).

Change-Id: I2d1673f8c1a4ade9aa880a95137491614fd8e102
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421884
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-04-11 12:05:37 -07:00
Paul Berry edfc713bf4 Add indications of which classes are sealed to api.txt.
Whether or not a class is sealed is relevant to the API, since it's a
breaking change to add a new subtype.

Change-Id: I73083491b741152aefa92a3818da878ed94a2b51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420843
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-04-08 09:37:40 -07:00
Paul Berry 29c24dbe27 [analyzer] Annotate experimental and deprecated APIs in api.txt file
It occurred to me that it might make it easier to code review changes
to `api.txt` if it included annotations of when an API was marked
`@experimental` or `@deprecated`.

Change-Id: If52eebe2e5086e92491d53bd9d63d3b18c79901e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413243
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-04 10:49:50 -08:00
Paul Berry a2718d9fab Add a machine-generated summary of the analyzer public API.
The summary is checked into source control in
`pkg/analyzer/api.txt`. It contains an entry for each type
declaration, extension, function, method, getter, or setter that is
part of the analyzer API, as well as the types of all functions,
methods, getters, and setters, and all type declarations referenced by
those types.

The tool `pkg/analyzer/tool/api/generate.dart` regenerates
`api.txt`. The test `pkg/analyzer/tool/api/generate_test.dart` checks
that generation of `api.txt` is up to date.

The intention is that `api.txt` will serve as an audit trail to (a)
detect unintentional changes to the analyzer public API, and (b) help
ensure that the developer experience team reviews intentional changes
to the analyzer public API. Once an appropriate OWNERS file has been
set up for the developer experience team, I intend to add an ownership
rule to require developer experience team review for this file.

The structure of the file is hierarchical, with top level nodes
representing libraries URIs, children of those nodes representing top
level elements declared or exported by those libraries, and
grandchildren of those nodes representing members of type
declarations.

If a type is considered part of the API, but it isn't exported by an
analyzer public API library (e.g., the type `Namespace`, which is
declared in `package:analyzer/src/dart/resolver/scope.dart`, but part
of the analyzer API due being exposed by
`LibraryElement.exportNamespace`, `LibraryElement.publicNamespace`,
`LibraryImportElement.namespace`, and so on), then it is listed under
the URI of the library that declares it.

If a type is not considered part of the API, but it is declared inside
`package:analyzer` and it is referenced by something in the API (e.g.,
`Workspace`, which is a private analyzer class but is the type of
`ContextRoot.workspace`), then instead of listing the members of the
type declaration, `api.txt` simply says `(non-public)` after the entry
for the type.

If a type is not considered part of the API, and it is not declared
inside `package:analyzer`, but it is referenced by something in the
API (e.g., `WatchEvent`, which comes from `package:watcher` but is
used in the type of `ResourceWatcher.changes`), then instead of
listing the members of the type declaration, `api.txt` simply says
`(referenced)` after the entry for the type.

If there are two distinct declarations in `api.txt` with the same name
(e.g., the two declarations of `AnalysisContext` from
`package:analyzer/dart/analysis/analysis_context.dart` and
`package:analyzer/src/generated/engine.dart`), then they are
disambiguated by appending an `@` symbol followed by an integer.

Change-Id: Ia2c856e79feebabb74aeb26f57c0a1eea7c63f68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409862
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-02-14 15:27:51 -08:00
Paul Berry d3de420bf8 Add a custom lint to sanity check the analyzer public API.
The new lint, called `analyzer_public_api`, verifies that the analyzer
public API satisfies the following properties:

- No method, function, getter, setter, or supertype in the public API
  refers to a non-public type.

- No `export` declaration in the public API shows a non-public name.

- No declaration in the public API has a name ending in `Impl`.

- No file in the public API has a `part` declaration that points to a
  file that's not in the public API. (If it did, then the other checks
  could be circumvented.)

A new annotation is added, `@AnalyzerPublicApi()`, allowing
declarations in `package:analyzer/src` or
`package:_fe_analyzer_shared/src` to be marked as part of the analyzer
public API. This is necessary because some parts of the analyzer
public API need to be declared elsewhere and then exported by the
analyzer.

A few lint violations have been ignored using `ignore:` comments. I
will try to clean these up in follow-up CLs.

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

Bug: https://github.com/dart-lang/sdk/issues/60058
Change-Id: I0047a73dec8a29e2ffe03dd3a90f7e41ca2e27b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409763
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-02-14 05:24:22 -08:00
Sam Rawlins 50c1d9e1a3 analyzer: Fix remaining comment reference issues
Change-Id: I345c8d25e9f27dedffc596a2040cd89e059eb46e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408880
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-02-11 07:12:20 -08:00
Daco Harkes 98e29db45c [native_assets] Disable experiment on stable and beta channel
We want to avoid users passing `--enable-experiment=native-assets` on
stable and beta, as we'd like to move fast and break things on the
experiment. This aligns the experiment with how the experiment is
working in Flutter: main and dev branch only.

Before this CL, dartdev did not check experiment flags. Unknown
experiments would fail in the VM. After this CL, dartdev checks the
experiment flags and errors out early.

Change-Id: I875ea3272f4b67342da19ea2e4be329a4b380573
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-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406660
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-02-04 03:36:43 -08:00
Parker Lougheed d678a7e191 [analyzer] Stop generating the diagnostics.md file
dart.dev now consumes the source YAML files, so generating the Markdown file is no longer necessary.

The contents of the YAML files are still verified as before.

Resolves https://github.com/dart-lang/site-www/issues/6387

Change-Id: I8b989b598ec3c7abef66242dceb9d5a481f43e39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407640
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-02-03 22:13:10 -08:00
Parker Lougheed 2e13d4d954 [linter] Doc and changelog updates
Change-Id: I64554034fc510afdab1c3e1dab18a3855fd31b09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406782
Commit-Queue: Marya Belanger <mbelanger@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
2025-02-03 15:08:15 -08:00
pq fa065954e5 [lint] new unnecessary_ignore error codes
(Fixes to follow)

Bug: https://github.com/dart-lang/sdk/issues/35234
Change-Id: I7a9255ffba7d9b0dc5e3ce9783f8f4ba63d8c854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404701
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-15 13:37:13 -08:00
pq 2dc6d31f8a [lint] new lint: unnecessary_ignore
See: https://github.com/dart-lang/sdk/issues/35234

As a follow-up, I'll update the reporting to skip generated files.


Change-Id: Icddcdf59269d82576eefd810671a3e992f2bcca5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2025-01-15 10:21:42 -08:00
Parker Lougheed fec029fa04 [analyzer] Mark latest lint and diagnostic docs as published
Also fixes a few minor typos.

Change-Id: I026bb91682440aa851f05f998c4c67c3d1a7a56e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403540
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
2025-01-07 18:12:37 -08:00
pq 259bf2445d [lint] unnecessary_underscores core implementation
(TODO: follow-up w/ improved documentation.)

Bug: https://github.com/dart-lang/sdk/issues/56595
Change-Id: I000ccf9012c659d7fbc942d8bc0fafce87dafc5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403201
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-06 16:20:18 -08:00
Konstantin Shcheglov 125ef4373d CQ. Remove unnecessary 'async' where no 'await'.
Change-Id: Ic19aa901b0451d93f05cefc1d12d6e7fc6d58468
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403261
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-06 15:16:40 -08:00
Sam Rawlins 02440ed34a Analyzer: Fix a few dozen comment references
Change-Id: I4a028f156aeaf8db532423c627aa9644f77b518c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402900
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-01-06 12:52:21 -08:00
Halil Durmus 1a8afa6bbf [vm/ffi] Allow omitting native types for @Native functions
This change simplifies working with `@Native`-annotated functions by allowing the native type to be omitted when it can be inferred from the Dart function's signature. While this was previously supported for `@Native` fields, it now applies to functions as well.

Before this change, you needed to specify the native type explicitly:
```
@Native<Void Function(Pointer)>()
external void free(Pointer p);
```

After this change, the native type can now be omitted if it's clear from the Dart signature:
```
@Native()
external void free(Pointer p);
```

TEST=tests/ffi/native_assets/*

CoreLibraryReviewExempt: VM only
Closes: https://github.com/dart-lang/sdk/issues/54810
Change-Id: Ied5407fcd2f49d85284cb7817f0c8cad2a73626b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400840
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Moritz Sümmermann <mosum@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-12-20 02:05:40 -08:00
Halil Durmus bb483f34a3 [vm/ffi] Allow configuring the variable dimension of variable-length arrays
TEST=tests/ffi/*

CoreLibraryReviewExempt: VM only
Closes: https://github.com/dart-lang/sdk/issues/52366
Change-Id: I545a323f48d955b591cedf2dae7106d9004242e2
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398621
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-12-09 22:02:56 +00:00
Sam Rawlins c0d4aa256d analyzer: Move strong_mode.dart and inference_error.dart
strong_mode.dart only contains a class, InstanceMemberInferrer, so it
can be named after that. InstanceMemberInferrer is only used by
`top_level_inference.dart`, so we move it to the same directory.

inference_error.dart just doesn't belong in the task directory. I think lib/src/error would be a fine location.

Change-Id: I6f36b1e8267bcf76f2e48aace4c93a719422dc21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399201
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-12-06 17:45:32 +00:00
Sam Rawlins a330ab1ee7 analyzer: Remove intermediate AnalyzerErrorCode
This class provides no value between ErrorCode and other subclasses.
Only private API is affected.

Change-Id: Ieebaccba993a8e7f460df0be984c71b8b27a23de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398582
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2024-12-04 16:57:20 +00:00
Erik Ernst e88f0811f9 Shortened the documentation of unsafe_variance
It is now 69 lines, and not the longest.

Change-Id: Ibf618c2356f0bcf90ab3a4f5661a094f53382b22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395523
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-29 14:36:49 +00:00
pq 107995fcdb [diagnostics] use_build_context_synchronously message fix
Picking up abandoned change: https://dart-review.googlesource.com/c/sdk/+/395461

Change-Id: Id5a876dec73870bb379e9ad89226669272ebf673
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396382
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
2024-11-19 22:12:43 +00:00
Erik Ernst 7b71ed17b2 Introduce the lint unsafe_variance
This CL implements a new lint, `unsafe_variance`. This lint emits a
warning whenever an instance member declaration has a signature where
a type variable declared by the enclosing class/mixin/enum occurs in
a non-covariant position in the return type (including the type of
an instance variable).

Issues: https://github.com/dart-lang/linter/issues/4111, with goals related to https://github.com/dart-lang/language/issues/296 and https://github.com/dart-lang/language/issues/524.

Change-Id: I1352d71d61fece03a432ccf0d98825a69e3a457f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384700
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-11-15 09:28:52 +00:00
Konstantin Shcheglov 1747e2da4b Elements. Migrate tool/benchmark/heap/flutter_elements.dart
Change-Id: Ie60dbfbba92d9717fb4fb0e3709be2a24f1aa39a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395084
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-13 20:36:01 +00:00
Brian Wilkerson 365941b268 Document some lint diagnostics
Change-Id: I38ba6f77a7d25e3f4716c2b2432b790c973c5650
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390303
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-11-08 00:49:18 +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
Samuel Rawlins 81f4b71293 Reland "Reapply "analyzer: separate unused_element_parameter from unused_element""
This reverts commit b3f31a0440.

Reason for revert: Customer tests are now disabled.

Original change's description:
> Revert "Reapply "analyzer: separate unused_element_parameter from unused_element""
>
> This reverts commit b551690c56.
>
> Reason for revert: flutter customer tests failing: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8738601049545714785/+/u/run_test.dart_for_customer_testing_shard_and_subshard_None/stdout
>
> Original change's description:
> > Reapply "analyzer: separate unused_element_parameter from unused_element"
> >
> > Fixes #49025. Fixes #48401
> >
> > This allows users to blanket ignore unused_element_parameter without
> > ignoring unused_element. They are reported in distinct situations so it
> > is valid to separate them.
> >
> > This reverts commit b888da751e.
> >
> > Change-Id: I8ea52fcdcb491c140c1283602d6911c939e78d50
> > Tested: trybots
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381882
> > Reviewed-by: Ben Konyi <bkonyi@google.com>
> > Commit-Queue: Samuel Rawlins <srawlins@google.com>
> > Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
>
> Change-Id: Ie0df2f4be45e5db2fa255dcf8c30ddf8408c155b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382420
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Reviewed-by: Matan Lurey <matanl@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: Icbe69690e83daecc5a0649d2f632ffc33ba6394c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386722
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Matan Lurey <matanl@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-10-30 16:56:16 +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
Kallen Tu 1bf5482e1e Enable 'wildcard-variables' feature flag.
This CL enables the wildcard variables feature by default in Dart 3.7.

Local variables and parameters named `_` are now non-binding and they can be declared multiple times without collisions. All wildcard variable declaration types that have this behavior are described in the
wildcard variables specification: https://github.com/dart-lang/language/blob/main/accepted/future-releases/wildcard-variables/feature-specification.md.

Top-level variables, top-level function names, type names, member names, etc.
are unchanged. They can be named `_` and used as they are today.

These are a few examples of where wildcard variables can be used:
```dart
Foo(_, this._, super._, void _()) {}

typedef T = void Function(String _, String _);

main() {
  var _ = 1;
  int _ = 2;

  list.where((_) => true);
}
```

Bug: https://github.com/dart-lang/sdk/issues/55673
Fixes: https://github.com/dart-lang/sdk/issues/55654
Change-Id: I80e904d39b364f5e54b8406b4db02ec40ecc9db0
TEST=Existing tests, language tests for wildcards.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381311
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2024-10-15 19:12:31 +00:00
Sam Rawlins 9baaa5f141 Reland "analyzer: Write out qualified extension names in error messages"
This is a reland of commit 10c1d883df

This includes a fix in listener.dart to not null-assert on an
element's name (`element.name!`). This fixes a problem in google
internal code.

Original change's description:
> analyzer: Write out qualified extension names in error messages
>
> Fixes https://github.com/dart-lang/sdk/issues/56269
>
> Change-Id: I025966fd4aa3d7c5b71175321f21f95e8c41f086
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388580
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I6c20cf023af26b2d3b0fe9d8193f5e067719da8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389587
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-11 20:08:31 +00:00
Alexander Thomas d4aa30a3ba Revert "analyzer: Write out qualified extension names in error messages"
This reverts commit 10c1d883df.

Reason for revert: g/dart-sdk-rolls/MOLCzv4S-kQ

Original change's description:
> analyzer: Write out qualified extension names in error messages
>
> Fixes https://github.com/dart-lang/sdk/issues/56269
>
> Change-Id: I025966fd4aa3d7c5b71175321f21f95e8c41f086
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388580
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I613695e90c96e5ffdb4dc56e729dc34be385f5fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388823
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Alexander Thomas <athom@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2024-10-08 15:07:38 +00:00
Sam Rawlins 10c1d883df analyzer: Write out qualified extension names in error messages
Fixes https://github.com/dart-lang/sdk/issues/56269

Change-Id: I025966fd4aa3d7c5b71175321f21f95e8c41f086
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388580
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-07 18:01:54 +00:00