Commit Graph

697 Commits

Author SHA1 Message Date
Sam Rawlins aad9e57674 Revert "Revert "[analyzer] new warning for nullable '==' parameter type""
This reverts commit 885457e1d3.

[analyzer] new warning for nullable '==' parameter type

This rule checks that a parameter to an `operator ==` implementation has
a non-nullable type.

I intentionally did not enforce, in this rule, that the parameter is
exactly `Object`. It is legal to narrow the parameter type to a
different non-nullable type, like `int`. I can't imagine doing it, but
it seems to be unrelated to whether the type should be nullable or not.

Fixes https://github.com/dart-lang/linter/issues/3441

Replaces https://github.com/dart-lang/linter/pull/3923

Change-Id: Ic0be2bfebaf59b0336e9a3a58e5b7f5359eb8646
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291042
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-14 23:58:12 +00:00
Daco Harkes 069e617ef4 [analyzer/ffi] Fix Unwrap typed data error messages
Fixes issues reported by:

TEST=pkg/analyzer/test/verify_diagnostics_test.dart

* Fixes error messages on asFunction.
* Fixes validation by introducing Uint8List to mock sdk.
* Removes unused typed_data import in example snippet.
* Fixes error locations in example snippets

Bug: https://github.com/dart-lang/sdk/issues/44589
Change-Id: I82261eea5e55cbafa686865a92131a449a7642f5
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-mac-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340921
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-12-12 14:32:57 +00:00
Brian Wilkerson 6ea4aa3070 Docs for additional extension type diagnostics
I think these are the last of the diagnostics added for extension types.

Change-Id: I86744f8cab2683c5c6fb18a59e92a9c0ab7ff672
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338582
Reviewed-by: Marya Belanger <mbelanger@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-07 01:23:12 +00:00
Paul Berry 9c3044fe2a Add support for string concatenation to the wolf analysis prototype.
The AST-to-IR conversion stage now handles the `AdjacentStrings` and
`StringInterpolation` AST nodes. This required adding the `concat`
instruction.

Although this support is not strictly necessary for the
proof-of-concept of wolf analysis, the presence of the `concat`
instruction will make testing of some later analysis stages easier,
notably SSA analysis, since it is a non-trivial operation that
produces a fresh value from one or more previous values.

Change-Id: I0915e0413db51e4c67617f61d8facc4e84909a7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339640
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-12-04 22:36:57 +00:00
Sam Rawlins 3b648e4635 analyzer: Support more complex flutter assets declarations
Fixes https://github.com/dart-lang/sdk/issues/54038

The main feature is a small expansion to what is allowed in the `flutter / assets` field. We used to enforce that the `assets` field is a list, and that each value is a string. Now we enforce that:

* the `assets` field is a list
* an asset is either a string, or
* an asset is a map, with at least a 'path' key, with a string value.

This requires deprecating the `ASSET_NOT_STRING` code, and introducing
three others:

* ASSET_MISSING_PATH
* ASSET_NOT_STRING_OR_MAP
* ASSET_PATH_NOT_STRING

In addition I cleaned up a UX issue: Several codes referenced an 'asset' key, but it should be 'assets'. (In addition, the `ASSET_FIELD_NOT_LIST` code should be `ASSETS_FIELD_NOT_LIST` but I did not fix that.)

I also refactored all of the code to be more modern:

* Use `var` instead of types in declarations
* Short circuit error-and-return with `if (foo is! YamlMap)`. We didn't use to have promotion here, but this led to a wild amount of nesting (if, if, for, if, if, else, if!).

Change-Id: Ia489ea631f7d1027fdb84a9a682c831752c5835c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338593
Reviewed-by: Marya Belanger <mbelanger@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-04 21:10:31 +00:00
Brian Wilkerson d91f3a113e Add diagnostic docs for extension types
I'm fairly sure there will be other diagnostics added later, so this
isn't everything, but it covers the diagnostics that are currently
implemented in the analyzer.

Change-Id: I27100c9a76e6db4fb2b0bf8b9bc6b0b2c326707f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322442
Reviewed-by: Marya Belanger <mbelanger@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-28 06:09:10 +00:00
Paul Berry 4016197b30 Add support for await, yield, and is checks to the wolf analysis prototype.
The AST-to-IR conversion stage now handles the AwaitExpression,
YieldStatement, and IsExpression AST nodes. This required adding the
`await_`, `yield_`, and `is_` instructions.

I believe this completes the proof-of-concept phase of AST-to-IR
conversion. I plan to move on now to implementing some lint rules
based on the IR representation.

Change-Id: I5f6e920dd04ca23d6b90d1522abf32955f757bc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337280
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 18:54:10 +00:00
Parker Lougheed 2f30295254 [analyzer] Correct invalid_dependency diagnostic message
Fixes https://github.com/dart-lang/sdk/issues/53217

Bug: https://github.com/dart-lang/sdk/issues/53217
Change-Id: I2b802adda2ff6403d279dc2f6cffc36f6f8047d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337302
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Marya Belanger <mbelanger@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
2023-11-21 18:46:06 +00:00
Paul Berry 88286dc100 Add support for simple loops to the wolf analysis prototype.
The AST-to-IR conversion stage now handles the DoStatement and
WhileStatement AST nodes, as well as simple ForStatement nodes (those
whose `forLoopParts` is `ForPartsWithDeclarations`). This required
adding the `loop` instruction. Unlabeled `break` and `continue`
statements are also supported.

Change-Id: Iaa46245755087e9f905988d65c4c2e0c33d283ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337041
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 18:10:03 +00:00
Paul Berry 099721d8a2 Add support for MethodInvocation to the wolf analysis prototype.
The AST-to-IR conversion stage now handles the MethodInvocation AST
node (which is used for both method invocations and top level function
invocations).  This required adding the instruction `identical`, to
support invocations of the `identical()` function.

Change-Id: I7a4204f50c770874ff913e2cbeabb997958025c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336829
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 14:58:59 +00:00
Paul Berry f03646e2fc Add more simple flow control support to the Wolf analysis prototype.
The AST-to-IR conversion stage now handles if statements, conditional
expressions, unary `!`, and binary `!=`. This required adding the
instruction `not`.

Change-Id: I2c87f95d8dfa1967ebe6c92c789c16254779c5bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336821
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 14:16:29 +00:00
Paul Berry deebb52c2b Add support for null shorting expressions to the Wolf analysis prototype.
The AST-to-IR conversion stage now handles null-shorting property
accesses (both for reads and writes). This required adding the
following instruction types: `eq`, `block`, and `brIf`.

In order to make `eq` easier to test, support was also added for
AST-to-IR conversion of testing binary expressions using `==`.

The way null shorting is encoded in the IR is by issuing a `block`
instruction when null shorting starts, and an `end` instruction when
it terminates. Anywhere a null check appears within the null shorting
expression, the null check uses a `brIf(0)` instruction to branch to
the `end` in the case a `null` is found. To make it easier to keep
track of when `block` and `end` instructions need to be generated,
`RawIRWriter` keeps track of a count of the current nesting of control
flow contsructs.

In order for the interpreter to find to the appropriate `end`
instruction when a branch is taken, a new scope analyzer is
added. Later CLs will expand on it and use it for static analysis as
well.

Change-Id: I09ca34eaa900d47f7a4014cbc8db2a48a1d69e1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336800
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 00:32:19 +00:00
Daco Harkes df4ef72c01 [vm/ffi] Remove deprecated FfiNative
TEST=pkg/analyzer/test/
TEST=CI build with class removed from `dart:ffi`

Closes: https://github.com/dart-lang/sdk/issues/53923
CoreLibraryReviewExempt: VM & dart2wasm only.
Change-Id: I45a39b623754f9f1b65cac55ea9adae390199f5d
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm64c-try,analyzer-analysis-server-linux-try,analyzer-mac-release-try,dart-sdk-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336960
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-11-20 13:16:28 +00:00
Konstantin Shcheglov 8b564e0bea Enable 'unnecessary_breaks' in analyzer/.
Change-Id: I46615f08175db25f24abf341376d571f270756cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336831
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-11-19 17:31:18 +00:00
Paul Berry 4dea6268f2 Add support for properties to the Wolf analysis prototype.
The AST-to-IR conversion stage now handles reads and writes of
properties, whether through a `SimpleIdentifier` (via implicit
`this`), a `PrefixedIdentifier`, or a `PropertyAccess` AST node. In
order to make this easier to test, support was also added for
parenthesized expressions.

This required adding the following instruction types: `call` and
`shuffle`. To allow for thorough testing, support for these
instruction types was added to the interpreter and validator.

Change-Id: Ic60452422a877f358b0cad31b3c5664fd0585809
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335701
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-11-18 14:14:48 +00:00
pq fe6950eceb enable flutter_style_todos
Change-Id: Ic82963b754404d54e37f5fb03819aebc3fa67954
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336502
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-11-15 23:04:19 +00:00
Paul Berry 75d943bf97 Reland "Add support for non-late local variables to the Wolf analysis prototype."
This is a reland of commit b76d60340d

Original change's description:
> Add support for non-late local variables to the Wolf analysis prototype.
>
> The AST-to-IR conversion stage now handles function parameters, local
> variable declarations, `this`, and reads and writes of local
> variables. In order to make this easier to test, support was also
> added for block function bodies, expression statements, and return
> statements.
>
> This required adding the following instruction types: `alloc`, `br`,
> `drop`, `dup`, `readLocal`, `release`, and `writeLocal`. To allow for
> thorough testing, support for these instruction types was added to the
> interpreter and validator.
>
> Change-Id: Iedef6aa75297081d128e89a2ac24019a198cf948
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335505
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Phil Quitslund <pquitslund@google.com>

Change-Id: I660947ff7adc6173508dcd69f625ced7e1d35721
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336202
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-11-15 14:55:05 +00:00
Paul Berry 9f1eb8f10a Revert "Add support for non-late local variables to the Wolf analysis prototype."
This reverts commit b76d60340d.

Reason for revert: Cbuild failures (old version of package:checks used internally)

I'll fix the internal code to use the latest package:checks before re-landing.

Original change's description:
> Add support for non-late local variables to the Wolf analysis prototype.
>
> The AST-to-IR conversion stage now handles function parameters, local
> variable declarations, `this`, and reads and writes of local
> variables. In order to make this easier to test, support was also
> added for block function bodies, expression statements, and return
> statements.
>
> This required adding the following instruction types: `alloc`, `br`,
> `drop`, `dup`, `readLocal`, `release`, and `writeLocal`. To allow for
> thorough testing, support for these instruction types was added to the
> interpreter and validator.
>
> Change-Id: Iedef6aa75297081d128e89a2ac24019a198cf948
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335505
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Phil Quitslund <pquitslund@google.com>

Change-Id: I4ae22c6e0dfcd9ae7d60c994b5bde8dc24158105
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335950
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-11-14 17:24:57 +00:00
Daco Harkes 326cf03995 [analyzer/ffi] Fix error message
Closes: https://github.com/dart-lang/sdk/issues/54036
Change-Id: I273822e044efdb5829f81cfb8a8ed17a34680280
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-14 17:03:28 +00:00
Paul Berry b76d60340d Add support for non-late local variables to the Wolf analysis prototype.
The AST-to-IR conversion stage now handles function parameters, local
variable declarations, `this`, and reads and writes of local
variables. In order to make this easier to test, support was also
added for block function bodies, expression statements, and return
statements.

This required adding the following instruction types: `alloc`, `br`,
`drop`, `dup`, `readLocal`, `release`, and `writeLocal`. To allow for
thorough testing, support for these instruction types was added to the
interpreter and validator.

Change-Id: Iedef6aa75297081d128e89a2ac24019a198cf948
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335505
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-11-14 14:12:31 +00:00
Paul Berry ba42706e66 Begin developing code for "Wolf analysis".
Wolf analysis is an experimental part of the analyzer that I intend to
use as the basis for new, more advanced, lint rules and other
analyses. Its first phase will consist of lowering the abstract syntax
of each function or method to a stream of instructions for a minimal
stack machine.

This code implements the first few instructions for the minimal stack
machine (`function`, `end`, `literal`, and `drop`). These are
sufficient to express a simple function like:

    int f() => 0;

Which maps to the following instruction stream:

    function(int Function(), 0)
    literal(0)
    end

This code includes a validator that verifies that an instruction
stream is well-formed. In follow-up CLs I will add logic to convert an
analyzer AST to an instruction stream.

The internal representation of an instruction stream is code
genreated, because:

- I intend to add additional instructions in follow-up CLs, and I
  don't want to have to remember all the boilerplate for adding an
  instruction each time.

- Once the implementation is far enough along to start consuming large
  amounts of real-world Dart code, I would like to be able to
  investigate the performance effects of changing the internal
  representation. Code generation will make this a lot easier.

Change-Id: I4bc299d31ed108f6eebf9cca913d1484dbc9a3cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334644
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-11-08 17:50:43 +00:00
Konstantin Shcheglov 6137e93241 Extension type. Issue 53930. Report BUILT_IN_IDENTIFIER_AS_EXTENSION_TYPE_NAME.
Bug: https://github.com/dart-lang/sdk/issues/53930
Change-Id: Ibf88b678cc45147f308de68614d6d127323b822a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333600
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-03 23:17:30 +00:00
Keerti Parthasarathy c31be01bbe Improve message when generating error ARGUMENT_TYPE_NOT_ASSIGNABLE for records.
Fixes BUG: #53580

Change-Id: I4c5a7b5147875ced2319ba36a396067a5ce1a657
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330668
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-10-18 17:56:49 +00:00
Konstantin Shcheglov f4080e7ae3 Heap. Drop XyzLinkedData after reading.
All results
--------------------------------
flutter_elements
  reachableObjects
    count: 11774300
      change: -7.92% -1012105
    size: 951741119 = 929434 KB = 907.7 MB
      change: -4.48% -44650680 = -43604 KB = -42.6 MB
  _SimpleUri
    count: 3112
    size(shallow): 248960 = 243 KB
    duplicateCount: 0
  InterfaceTypeImpl
    count: 157899
      change: -0.01% -16
    size(shallow): 10105536 = 9868 KB = 9.6 MB
      change: -0.01% -1024 = -1 KB
  LinkedData
    count: 0
Change-Id: If98590f84d050c7c03d2a5e81d2e23353e7c02ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330382
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-10-16 20:51:02 +00:00
Konstantin Shcheglov c8f8ae8afd Heap. Add --write-file option, print changes relative to the results in the file.
Output example:

All results
--------------------------------
flutter_elements
  reachableObjects
    count: 3487130
      change: -1.19% -41855
    size: 335892119 = 328019 KB = 320.3 MB
      change: -0.58% -1949720 = -1904 KB = -1.9 MB
  _SimpleUri
    count: 3061
    size(shallow): 244880 = 239 KB
    duplicateCount: 0
  InterfaceTypeImpl
    count: 40821
    size(shallow): 2612544 = 2551 KB = 2.5 MB

Change-Id: I371ac4f6c1bf4d70238b47fc9f28bbc3f07abcf6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330244
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-10-13 01:22:29 +00:00
Konstantin Shcheglov c63d228ad6 Heap. Measure InterfaceTypeImpl instances.
The optimization was already done previously.

Before:
--------------------------------
flutter_elements
  reachableObjects
    count: 14531246
    size: 1107667559 = 1081706 KB = 1056.4 MB = 1.03 GB
  _SimpleUri
    count: 3112
    size(shallow): 248960 = 243 KB
    duplicateCount: 0
  InterfaceTypeImpl
    count: 1904467
    size(shallow): 121885888 = 119029 KB = 116.2 MB


After:
--------------------------------
flutter_elements
  reachableObjects
    count: 12839510
    size: 999428703 = 976004 KB = 953.1 MB
  _SimpleUri
    count: 3112
    size(shallow): 248960 = 243 KB
    duplicateCount: 0
  InterfaceTypeImpl
    count: 211922
    size(shallow): 13563008 = 13245 KB = 12.9 MB
Change-Id: Ibcfa0b4c1c61cb074764fb9ed1884086064d24e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-10-12 19:09:21 +00:00
Martin Kustermann a5ba26babb Make [ByteData] of [Uint8List] based on the same bytes
A [Uint8List] may be a view into a larger buffer. When we want to create
a corresponding [ByteData], we should ensure the byte data is based on
the same bytes (and not e.g. include additional heading/trailing bytes)
by using `bytes.buffer.asByteData(bytes.offsetInBytes, bytes.length)`

Change-Id: Ifd7b59a41b8ee0431319d5cf13a2e63da3dfb00e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330080
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-10-11 14:26:48 +00:00
Konstantin Shcheglov b7d3c47d13 Adds benchmark measuring memory consumption of live objects after analyzing flutter.
Will warm up the memory cache and then measure how much live memory the analyzer consumes after visiting all elements with the warmed up cache.

All results
--------------------------------
flutter_elements
  reachableObjects
    count: 9071480
    size: 799672175 = 780929 KB = 762 MB
  _SimpleUri
    count: 3112
    size(shallow): 248960 = 243 KB
    duplicateCount: 0

Change-Id: I75209f88f6f615172127cd439afe9d0cd83b1c4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329682
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-10-10 17:54:08 +00:00
Parker Lougheed 5c9c383224 [analyzer] Mark 'MISSING_DEPENDENCY' diagnostic as having published docs
Also makes a few copy improvements.

Published docs: https://dart.dev/tools/diagnostic-messages#missing_dependency

Change-Id: Ifdf79b609b2e6ff1c3c8044dbfae2b2cee1a91f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329840
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-10-09 21:42:26 +00:00
Keerti Parthasarathy 3263977c48 Add a validator for missing dependencies in pubspec file.
Change-Id: Ief1986d4eb5a8095ea6a21d81239e6dd08b9a0b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-09-29 15:01:05 +00:00
Kallen Tu 742ba5c20d [analyzer] Change the const evaluation result of variables to be Constant.
We rely on the result of the `ConstantVisitor` to indicate whether we have an error or a valid constant value.

This CL changes `evaluationResult` to be a `Constant` and changes error reporting to occur at a POE for evaluating a constant.

Last few chunks of cleaning up the constant evaluator, woo!

Change-Id: Icd41a4fcbab0626df36c6a83cd60ecbb59c2dcf0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324573
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-09-22 16:13:10 +00:00
Parker Lougheed 304cdc951f [analyzer] Update INVALID_REFERENCE_TO_THIS docs to match spec
I tried my best to match terminology with other existing diagnostic docs.

Fixes https://github.com/dart-lang/site-www/issues/5172

Change-Id: I8c59bcdd6b0e9315dd35e120e3a9536d7a6c9930
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325923
Reviewed-by: Marya Belanger <mbelanger@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-09-19 15:10:39 +00:00
Johnni Winther 1683fd5c16 [_fe_analyzer_shared] Ensure beginToken on class, enum, mixin, extension and extension type
This passes the first token of these top level declaration directly
to the endX listener method.

In the CFE this is used to ensure that can handle the new modifiers in
the textual outline. Furthermore, support for extension types is added
and having an "unknown chunk" now results in an error. The latter should
help us keep the textual outline up-to-date wrt new features.

Change-Id: I813d6162b6cba0a2bf550ed33a6091abf9bf49f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324702
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-09-15 13:01:10 +00:00
Liam Appelbe e8d7425c4e [vm/ffi] Closure callbacks for sync callbacks
Bug: https://github.com/dart-lang/sdk/issues/52689
Change-Id: I54be397cfbf8519fe5b5a51b793fe46d602124d9
Fixes: https://github.com/dart-lang/sdk/issues/52689
Bug: https://github.com/dart-lang/sdk/issues/53096
TEST=isolate_local_function_callbacks_test.dart, plus generated tests and additions to existing tests
CoreLibraryReviewExempt: The isolate and FFI packages are VM-only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317060
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-08-25 03:35:44 +00:00
Johnni Winther b1594fa130 [parser] Handle invalid extension type header in error recovery
This expands the existing recovery for class headers to handle
invalid, out-of-order, and duplicate clauses in extension type
declaration headers.

Change-Id: I7b33b91cc718e4c0673137121b8d083fa0ef1562
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321900
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-08-24 11:20:18 +00:00
Sam Rawlins 7ee87f8601 [analyzer] Remove all support for strong-mode
This looks pretty beefy; it is more-or-less 3 parts:

* Removing the `implicit-casts: false`, `implicit-dynamic: false`
  modes:
  * Remove `AnalysisOptionsFileConfig.implicitCasts|implicitDynamic`
  * Remove `AnalysisOptionsImpl.implicitCasts|implicitDynamic`
  * Remove `TypeSystemImpl.implicitCasts`
  * Remove all behavioral tests of the modes
  * Remove Analysis Options-parsing code that handled `strong-mode`
* Remove ability to fix deprecated modes (introduced before Dart 3).
* Move some non-generated AnalysisOptionsHintCodes and
  AnalysisOptionsWarningCodes to be generated. As
  `AnalysisOptionsHintCode.STRONG_MODE_SETTING_DEPRECATED` was the
  last `AnalysisOptionsHintCode` code, there were problems with the
  code-generator, unless I moved these non-generated codes.
  * `DEPRECATED_LINT_HINT`, `DEPRECATED_LINT_HINT_WITH_REPLACEMENT`,
    `DUPLICATE_RULE_HINT`, `INCOMPATIBLE_LINT`, `UNDEFINED_LINT`.
  * Those codes are then added to error_fix_status.yaml.

Change-Id: Ic165b60ca85f08f92886433eac5f5da5b7dd5021
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316483
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-08-17 17:07:37 +00:00
Parker Lougheed d2bae29d84 [analyzer] Enable highlighting in docs for yaml diagnostics
Change-Id: Ifc0cf843603547c586c7d0d43828b56a3e8d5114
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320720
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-08-14 22:35:05 +00:00
Parker Lougheed 0140ecd9dd [analyzer] Clarify obsolete colon separator diagnostic messaging
Clarify that the diagnostic applies to optional named parameters, that support is already removed, and showcase the symbols themselves for extra clarity.

Change-Id: I0920793452bb8b0aaba04cbc96e89bb8acd571c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320442
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-08-14 16:44:03 +00:00
Brian Wilkerson 083b3e5150 Update the generated diagnostic docs
This should fix one of the issues turning the bots red.

Change-Id: I5729e1f4cb8dd12b33391113166581d5d6618e67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320260
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-08-11 22:55:35 +00:00
Parker Lougheed 6f127b2b47 [analyzer] Update list of unverified docs
No longer marks a few error codes as unverified if the issue no longer exists or an adjustment of the offset/length was needed.

Change-Id: I78aa557dcffeafb5c3af40b978fa23ba0bc93a0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319640
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-08-10 20:21:08 +00:00
Parker Lougheed 061396f38d [analyzer] Add back removed diagnostic messages
It adds them back and specifies `removedIn: "3.2"` to prevent generation of error codes.

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

Bug: https://github.com/dart-lang/sdk/issues/53120
Change-Id: Icc6e861f317b582d15d463867f08ba70ffee9f2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-08-09 16:53:36 +00:00
Parker Lougheed 401fa6130f [analyzer] Mark diagnostics as published and fix spelling mistakes
Change-Id: Ib9bc435b88611724cf0527d942990991ecf8d024
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-08-09 15:16:03 +00:00
Parker Lougheed 1b8870bbb1 [analyzer] Don't generate error codes for removed diagnostics
Also renames 'removed' to 'removedIn' to better indicate it is looking for a version, not a boolean.

Change-Id: If3a6708ba32460305e89ba59c4a58ce2ad284e6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319282
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-08-09 04:08:23 +00:00
Sam Rawlins 5c9b4ed2cb [analyzer] Remove support for pre-const-update-2018 code
Dart 3's minimum language version is 2.12. google3's is 2.9.

Change-Id: Icd892b0fcec7f2ce9fa813a108519c0bbbd29a52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317040
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-08-01 21:31:52 +00:00
Jonas Finnemann Jensen 1a4c889fbc Fix verify_diagnostics_test, #53020
Change-Id: Ida68ed3995c4db9be34fa0ce90b6683fc826f8a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315822
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-31 16:42:29 +00:00
Sam Rawlins 415ff8ece8 [analyzer] Remove all checks for set-literal and extensions enablement
And using Future from dart:core, which was not enabled until Dart
2.1.0.

Dart 3's minimum language version is 2.12. google3's is 2.9.

Change-Id: Id31d92007e685447ff217bdccf8161c8fd6ce6e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316863
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-30 00:12:59 +00:00
Sam Rawlins ab8736cf7c [analyzer] Remove all checks for ui-as-code enablement
Dart 3's minimum language version is 2.12. google3's is 2.9.

Change-Id: I8303b14de17b695e835cf9f8018f08731b51ec35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316526
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-27 02:43:38 +00:00
Samuel Rawlins 008cb0bbc1 Revert "Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT"
This reverts commit a458bab09a.

Reason for revert: broke flutter snippet tests, and maybe customer tests

Work towards https://github.com/flutter/flutter/issues/131096

Original change's description:
> Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT
>
> Fixes https://github.com/dart-lang/sdk/issues/49025
>
> Change-Id: I401093e5b76bcf707060ce022c346e26c6807aa0
> Tested: try-bots
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303261
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

Change-Id: Ib0c9afc4911efd620013896fb895ab7825c50aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315940
Commit-Queue: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-24 16:25:07 +00:00
Jonas Finnemann Jensen c77b7a6eda Add diagnostics for platforms key in pubspec.yaml.
**Context:**
The `platforms` field is used to indicate what platforms are supported
by a given package. It's only relevant when publishing to pub.dev, or
similar package repository. If no `platforms` fields is supplied the
platforms will be detected based on `import` statements, also accounting
for conditional imports. See [pubspec reference][1] for details.

These diagnostics aim to help developers discover a misconfigured
`platforms` fields, which they would otherwise only discover when
publishing to [pub.dev][2].

[1]: https://dart.dev/tools/pub/pubspec#platforms
[2]: https://pub.dev

Change-Id: I7b9ea5e371bb1cce6410d32fe6f38c49bc2ff69e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309661
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
Commit-Queue: Jonas Jensen <jonasfj@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-07-21 12:04:19 +00:00
Sam Rawlins a458bab09a Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT
Fixes https://github.com/dart-lang/sdk/issues/49025

Change-Id: I401093e5b76bcf707060ce022c346e26c6807aa0
Tested: try-bots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303261
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-20 18:33:58 +00:00