Commit graph

42030 commits

Author SHA1 Message Date
Devon Carew 8935cb0a53 [pkg] use package:lints/recommended.yaml as the default analysis config
Change-Id: I302b8e9d6568ac43ec4e9ba29b660e1528f4d61a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281223
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2023-02-08 16:56:05 +00:00
Chloe Stefantsova 85c2bd891b [cfe] Add basic support for pattern-for-in loops
Part of https://github.com/dart-lang/sdk/issues/49749

Change-Id: I7becfa2ef558fb483716d7d1bc195d858cc69094
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281660
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-08 15:54:19 +00:00
Paul Berry a66dcf1b77 Flow analysis tests: use a trailing comma for unary types
Change-Id: I0183c332492b298d5d3db70f7222111757a0e364
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281544
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-02-08 15:38:48 +00:00
Paul Berry 623f0bbfce front_end: fix integration with shared patterns logic for rest patterns in maps.
Rest patterns in maps are represented with a special distinguished
MapEntry that otherwise looks like `null: null`.  In the callback
methods `isRestPatternElement`, `getRestPatternElementPattern`,
`handleMapPatternRestElement`, and `getMapPatternEntry` we need to
recognize this MapEntry and treat it specially.

This will pave the way for integrating constant pattern handling
between the front end and shared logic.  (If we tried to integrate
constant pattern handling without doing this fix first, then map
patterns containing `...` would be retreated as though they contained
`null: null`, and hence they wouldn't be usable in irrefutable
contexts.)

Change-Id: Idcad97af6de49f3363fc777f54d5b6205bebf19d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281520
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-08 15:35:28 +00:00
Ömer Sinan Ağacan 73ee6d53a0 [dart2wasm] Attach stack traces to Error subtypes on throw
This implements this part of the language spec (section 17.10):

> If v is an instance of class Error or a subclass thereof, and it is
> the first time that Error object is thrown, the stack trace t is
> stored on v so that it will be returned by the stackTrace getter
> inherited from Error.

New passing tests:

- co19/Language/Expressions/Throw/stack_trace_t01
- co19/LibTest/core/Error/stackTrace_A01_t01
- co19/LibTest/core/IndexError/stackTrace_A01_t01
- corelib/error_stack_trace_test/none
- corelib/error_stack_trace_test/nullThrown
- language/stack_trace/error_runtime_test

Fixes #50608

Change-Id: I1d7df2337cce1be3ecbab0180def5769b8fe3e68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279966
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-02-08 14:53:36 +00:00
Daco Harkes 035b0c23a9 Revert "[analyzer/ffi] Disallow nullable struct fields"
Revert submission 279511

Reason for revert: Flutter dependencies are using nullable struct
fields and need to be migrated first
https://github.com/flutter/flutter/issues/120260

Reverted changes: /q/submissionid:279510 /q/submissionid:279511

Change-Id: I84d8ec03bc56e4cf9d18ae99954c89ae61eb233a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281601
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-02-08 08:51:28 +00:00
Daco Harkes 732e4a43d5 Revert "[vm/ffi] Disallow nullable struct fields"
Revert submission 279511

Reason for revert: Flutter dependencies are using nullable struct
fields and need to be migrated first
https://github.com/flutter/flutter/issues/120260

Reverted changes: /q/submissionid:279510 /q/submissionid:279511

Change-Id: I7ab66ef6c6b5f21303804b2930af4ad6aa000413
Tested: Revert
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281600
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-08 08:51:28 +00:00
pq 2192131b5e + remove_break fix (for unnecessary_breaks)
See: https://github.com/dart-lang/sdk/issues/49960

Change-Id: I67f3e58030aa800bebc045fc86114a5d9e5f7522
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281464
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-02-07 23:54:07 +00:00
Konstantin Shcheglov e86fe85aa4 Suppport ForEachPartsWithPattern in NodeReplacer.
Change-Id: I152f3c7b0500db9ad4ca633dd0f4491cea460f53
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281465
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-07 22:58:47 +00:00
Brian Wilkerson 22882c4e28 Add support for constant-requiring patterns
Change-Id: Iaad0ec10a35059da85a79823cbf5de5eadd8d4e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281344
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-02-07 22:18:06 +00:00
Stephen Adams aec79c2b3c [js_ast] Add annotations facility
'Annotations' allow client information to be attached to js_ast nodes.

I will be using this facility to embed resource identifers in the generated JavaScript AST to generate a map from files to the resource identifiers that they contain.

Change-Id: Id9012b303de0d2b3848a635bc34747f8c5101236
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281320
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-02-07 21:34:16 +00:00
Derek Xu c25308d003 [VM/Service] Fix generation of toJson() calls on dynamic variables
TEST=CI, manual testing

Issue: https://github.com/dart-lang/sdk/issues/51188
Issue: https://github.com/dart-lang/sdk/issues/51100
Fixes https://github.com/dart-lang/sdk/issues/51100
Change-Id: I4b7122df2e24534ed919aa0665dcf2a777c5deed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281463
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-02-07 21:28:36 +00:00
Paul Berry 832ae6722d Flow analysis: add support for relational patterns.
There are two new API methods: `equalityRelationalPattern_end` (for
relational patterns using `==` or `!=`, where some degree of flow
analysis is warranted) and `nonEqualityRelationalPattern_end` (for all
other relational patterns, where all we care about is making sure that
both the "matched" and "unmatched" branches are reachable).

I've moved most of the logic for constant patterns into
`equalityRelationalPattern_end`, since it's essentially the same logic
(except that `equalityRelationalPattern_end` also has support for
`!=`).  So now, `constantPattern_end` simply calls
`equalityRelationalPattern_end` in the case where pattern support is
enabled.

I also had to make a change to `RelationalOperatorResolution` to make
it possible to distinguish `==` from `!=`.

Bug: https://github.com/dart-lang/sdk/issues/50419
Change-Id: Idc5dbcfb02e3f8b57cfcccb3f46364fe34268ded
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280900
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-02-07 21:08:50 +00:00
Ahmed Ashour b5a8206c8b [analyzer] introduce UNNECESSARY_SET_LITERAL
Fixes #50900

Change-Id: I7c7535e3fa7dcd25bf11034790a14b1bdfc50a77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279962
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-02-07 21:05:08 +00:00
pq ad2da86f18 linter 1.33.0 rc
Some notes.

* There are a number of tests that should get decoupled from the linter being pulled into `DEPS`.  Instead of depending on the state of lints there, we should update the tests instead to use a more hermetic environment.  (See for example `options_rule_validator_test.dart` for how that might look.)


Downstream (blocking) fixes:

* https://github.com/flutter/flutter/pull/119736
* https://github.com/flutter/gallery/pull/878


Change-Id: I5671b0abde3eeda75513abaaf9fef3bcd5115f9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280054
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-02-07 20:56:35 +00:00
Ahmed Ashour 8e0b66b3c0 [analysis_server] remove UseConst
Use `AddConstant` or `RemoveConst` instead

Fixes #50803

Change-Id: Idf0b2f626558a8b2abb91eb0a4c4872f91e29632
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277120
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-02-07 20:27:01 +00:00
Mayank Patke 826df3415a [dart2js] Extend const simplifier to local/static reads and invocations.
We now attempt to evaluate
- final local variables with initializers
- final statics with initializers
- static or local function invocations if they just return an expression
by attempting to const-evaluate the initializer/returned expression.

Change-Id: I976863d950ba1609c5d8e6a21884ca56af0d2b4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275145
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2023-02-07 20:07:57 +00:00
Mayank Patke 397ed8673c [dart2js] Add phase 1 kernel transformer to simplify const conditionals.
Suppose we have code like

if (isDevMode) {
  // do foo
} else {
  // do bar
}

where isDevMode is const (or can be evaluated as const). In particular,
isDevMode can be controlled by compile-time options, like
bool.fromEnvironment.

We currently eliminate the dead branch during SSA, but that means we do
the work of compiling dead code in the previous phases. Instead, we can
recognize that the condition is const (or effectively const) and
eliminate the dead AST subtree directly.

Change-Id: Ia91da5ebc7fa496a1b963308c6e02d572cab936e
Bug: b/254543452
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270281
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-02-07 20:07:57 +00:00
Mayank Patke b028da6407 [dart2js] Add a 'FALSE' JS_GET_FLAG.
There are a few places in our runtime libraries where we have some code
guarded by `if (false)`. This is to ensure that the guarded code is
marked as used and compiled, but not emitted unless rewritten during
SSA. This pattern is somewhat brittle - a kernel
optimization/transformation which eliminates dead code may discard the
code.

Instead, we can write `if (JS_GET_FLAG('FALSE'))`, which will only be
written to `if (false)` and then discarded during SSA.

Change-Id: I8edc2b24e5fbeece1f042ff3d0c87d58e939bf84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271800
Reviewed-by: Stephen Adams <sra@google.com>
2023-02-07 20:07:57 +00:00
Srujan Gaddam ff01414b8f [dart:_js_interop] Add support for statically resolvable inline class interop members
Amends lowerings on dart2wasm and JS backends to work for external
constructors/factories and static members. Tests members with and
without renaming of members/classes/libraries. Note that this does
not add support for object literal factories yet.

Change-Id: I149bef7249c1a13a31eed9f3510256d407b1d3e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280056
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-07 18:47:23 +00:00
Srujan Gaddam d54addb789 [dart2wasm] Handle InlineTypes in visitors
TEST=dart2wasm no longer crashes on inline classes

InlineTypes can be treated as their underlying representation
types instead.

Change-Id: I802de0112f3f62024bc746e30b3db90506a0e159
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280620
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-02-07 18:47:23 +00:00
Srujan Gaddam 08feb43d6c [dart2js] Add support for InlineTypes in visitors and serialization
This is mostly to get the test bots running for tests that use
inline classes. It's possible there are other visitors that need
to be modified that this CL does not touch.

Change-Id: I9359f41a8dd51c290304126510122cc565902d98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280402
Reviewed-by: Stephen Adams <sra@google.com>
2023-02-07 18:47:23 +00:00
Brian Wilkerson e923274bb6 Compute the context type within patterns
Change-Id: I1f90f87477ed0bf9ea1c085bac11f769d9dbfcc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280404
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-02-07 18:39:19 +00:00
Paul Berry 3d01b0aac3 Flow analysis: add support for constant patterns.
Since matching a constant pattern implicitly performs an equality
check, we do the same flow analysis for constant patterns that we
would have done for an explicit equality test.  There are only two
user-visible behaviours:

- If the constant pattern is a `null` literal, then in the code path
  where the pattern fails to match, the scrutinee is promoted to a
  non-nullable.

- If the constant pattern and the scrutinee are both `null` literals,
  the pattern match is known to always succeed (so the code path where
  the pattern fails to match is marked as unreachable).

The first of these two behaviours is genuine useful to the user, since
it allows things like:

    switch (expr) {
      case null:
        ...
      ...
      default:
        // expr is known to be non-`null`.
    }

The second behaviour is not so useful, but seemed worth doing to
maximize code sharing and to keep the behaviour consistent between
pattern matching and explicit null checks.

Making this work required extracting some of the logic that was
formerly in `_FlowAnalysisImpl.equalityOperation_end` into a method
`_equalityCheck`, which understands how to analyze an equality check
regardless of whether it's an explicit equality expression or an
implicit part of a pattern.  It returns an `_EqualityCheckResult`,
which `equalityOperation_end` examines to determine exactly what needs
to be done to for an equality test in an expression context;
similarly, `_FlowAnalysisImpl.constantPattern_end` now calls
`_equalityCheck` and then does the right thing for patterns.

It was also necessary to extract the logic from
`nullCheckOrAssertPattern_begin` for handling null checks in patterns;
that logic is now in `_nullCheckPattern`, which is also called by
`constantPattern_end`.

In the process of testing this change, I discovered (and fixed) a
minor bug: when analyzing a switch statement or switch expression, we
were re-capturing the value of the scrutinee before visiting each
pattern.  This meant, for example, that we would analyze the following
code incorrectly:

    int? i = ...;
    switch (i) {
      case _ when f(i = ...):
        ...
      case null:
        ...
      default:
        // `i` should *not* be promoted to non-null here, because it's
        // not guaranteed to be the same as the value matched by `case
        // null` above.
    }

Bug: https://github.com/dart-lang/sdk/issues/50419
Change-Id: I4d30d6bc2673d9968e69f3384a37e1b2b9cc4a8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280861
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-02-07 18:24:54 +00:00
Konstantin Shcheglov ef474c9399 Add 'patternTypeSchema' to PatternAssignmentImpl and PatternVariableDeclarationImpl.
Change-Id: I02c3212ebf564755dfb1c0029d683bee1193d80c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281301
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-07 16:56:19 +00:00
Brian Wilkerson b23e801e7c Support completion in type argument lists
Change-Id: Ic861f571fcef15c2f4de082e23bf2521ad2b9402
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281283
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-02-07 16:01:54 +00:00
Sam Rawlins 503f386fb5 [analyzer] Move 4 more Hints to be Warnings, RE*
Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: I949e1f691889ac5a5ff4181b708cfe9e0bb1e1ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281303
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-02-07 14:55:40 +00:00
Brian Wilkerson 5d817747b5 Support completion in a list pattern
Change-Id: I0c01ff8aa7515b8f8f8b6dbb0a74aac0015e0460
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281222
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-02-07 14:44:58 +00:00
Paul Berry 7532b5b138 Flow analysis: store full EqualityInfo for pattern scrutinees.
This will make it possible to generalize the flow analysis logic we
already have for equality expressions and calls to `identical`, so
that we can use it for constant patterns (which implicitly do an
equality check) and relational patterns involving `==` or `!=`.

This requires adding a new method to the flow analysis API,
`FlowAnalysis.assignedVariablePattern`, to handle variable references
appearing inside a pattern assignment.  Previously we were able to use
`FlowAnalysis.write` for this purpose, relying on its call to
`getExpressionInfo` to gather the relevant information about the RHS
of the assignment.  But now, since we are calling
`equalityOperand_end` from `_pushScrutinee`, the expression info is no
longer available at the time we visit the variable reference.

Change-Id: I9a28bced97dcf6ee15674eaa4430910121185489
Bug: https://github.com/dart-lang/sdk/issues/50419
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280219
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-02-07 14:22:56 +00:00
Alexander Markov bd13fc128d [vm] Improve specialization of List factory constructors when named arguments are rearranged
When named argument are used before positional, front-end can insert
additional temporary variables in order to keep original evaluation
order. As a result, List factory specialization was not able to
match constant arguments such as 'growable: false' in the AST.

This change fixes this problem by adding extra unwrapping of final
variables before matching constant arguments during list factory
specialization.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/lists.dart
Fixes https://github.com/dart-lang/sdk/issues/51252

Change-Id: If69789ba15aed28a3c1f137a09b3b77f719f437e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281240
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-07 14:16:29 +00:00
Paul Berry 52ca2d74f7 Shared analysis tests: Fix error messages around isLegacyExhaustive.
The named parameter `isExhaustive` was renamed to `isLegacyExhaustive`
in https://dart-review.googlesource.com/c/sdk/+/274720, but the error
messages that result from not using it properly were not updated.
This change updates the error messages to reduce confusion when
writing tests.

Change-Id: I20664ef53b0e0e758f2d43d52d5d1747e4c499f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280660
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-07 13:55:48 +00:00
Ahmed Ashour 0175e5437b [cfe] report CannotAssignToFinalVariable
with final variable in `for in`

Fixes #49495

Change-Id: I1a75d526ca648d95e45b02195fa64181184be5d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281020
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-02-07 12:21:29 +00:00
Daco Harkes 897acba77f [frontend_server] Cleanup tests
Await unawaited futures and run formatter.

Change-Id: I2808b8cdc44ef9462e0c65d2ece72fdda9e114fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281180
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-07 10:06:50 +00:00
Jens Johansen e45a1b362a [analyzer] Receive stdin in an isolate to increase responsiveness
Before this CL, typing in a big file in IntelliJ on Windows could lead
to longer and longer latency (read: taking longer and longer from you're
finished writing and the code is error free until the editor doesn't
report an error --- I've reached 40 seconds for a simple print statement
in my testing).

This is caused by a number of things; this CL fixes the issue by
receiving data from stdin in an isolate.

Background:
* The IntelliJ plugin sends the whole file on every change in a file.
  Files can be big though, and e.g. `ast.dart` in the kernel package is
  almost 500 kb.
* The IntelliJ plugin sends the data in chunks of size ~8192 bytes.
* On Windows (but not Linux) it is also received in chunks of that size.
* Darts `LineSplitter` is currently quadratic in behavior
  (https://github.com/dart-lang/sdk/issues/51167) (to be fixed with
  https://dart-review.googlesource.com/c/sdk/+/280100)

Even with the fix of `LineSplitter`, when editing `ast.dart` in IntelliJ
on Windows, (as long as one is typing fast enough) we'll create a longer
and longer queue of messages (with more and more latency).
In testing I reached ~40 seconds of latency, i.e. after I was done
typing and there were no more errors it took ~40 seconds before the
Analyzer and the editor agreed.

I think what's happening is something like this:
* You type a character in IntelliJ in Windows.
* IntelliJ sends two requests: Updated content (the whole file, i.e.
  lots of data) and "give me completions".
* You type another character (I seem to type one character every ~150 ms
  when typing) and it sends two new requests.
* When receiving is slow it processes everything. So it updates the file
  and marks the file for being analyzed. Then it processes the
  completion requests which "forces" the file to be analyzed. This takes
  more than 150 ms, so it gets behind. More and more so for each
  character typed.

Receiving in an isolate means that once the main thread receives
(now via a `ReceivePort`) it receives more data and can now skip some of
the completion requests meaning that it doesn't analyze the file for the
"intermittent" updates.

Change-Id: I43507412abfddcfb903d90d86226172b291bdb47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280321
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-02-07 07:10:28 +00:00
Joshua Litt 4dc19b6bfb [dart2js] Ensure JavaScriptFunction gets emitted for allowInterop
Change-Id: I320653a46da31cfb626c41a3a2307b1d1626173a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280205
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-02-06 21:59:29 +00:00
Sam Rawlins 85ee8dbf42 [analyzer] Move 5 more Hints to be Warnings, NULL*
Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: I7f2364a4afedd59d481216b37836b46ce5638866
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280403
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-02-06 21:21:21 +00:00
Konstantin Shcheglov 007562a06a Report matchedTypeIsSubtypeOfRequired for cast pattern.
https://github.com/dart-lang/language/pull/2813

Change-Id: If8942efca4fa736cb24c625bc83963bbd69302f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281060
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-02-06 20:53:50 +00:00
Nicholas Shahan 5717d08a2d [test_runner] Add ddc-options to compiler configuration
Use explicit ddc-options to pass `--canary` flag to the compiler instead
of sniffing for a builder tag.

This just feels more expected and makes more sense if you are trying
to understand how the canary configurations compile tests differently
from the stable configurations.

Change-Id: I59b1e62d3839f6f992eea917ecbae240640fcd76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280783
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-02-06 18:58:34 +00:00
Danny Tuppeny 5b09a3db9a [analysis_server] Include Class/Enum/Mixin declaration names in occurrences
Fixes https://github.com/Dart-Code/Dart-Code/issues/4376.

Change-Id: I55cb9ca7947c828137e5e01c9b0fef4f7afe7ed4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281182
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-02-06 17:30:53 +00:00
Daco Harkes 4e7d71b593 [vm/ffi] Disallow nullable struct fields
TEST=tests/ffi/regress_51041_test.dart

Closes: https://github.com/dart-lang/sdk/issues/51041
Change-Id: I44d82c5f378c5d001bfb7526be87c179b8160be1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279511
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-06 16:29:42 +00:00
Daco Harkes 846fb2832e [analyzer/ffi] Disallow nullable struct fields
TEST=pkg/analyzer/test/src/diagnostics/invalid_field_type_in_struct_test.dart

Bug: https://github.com/dart-lang/sdk/issues/51041
Change-Id: Id3868a633f6627ebc0f528140a640e0c1dfe34ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279510
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-02-06 16:29:42 +00:00
Jens Johansen 1a6d6f7012 [parser] Add comments to calls
Change-Id: I66756be2c2d979dfbdd50c304f8b083abf2fc034
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280462
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-06 11:42:31 +00:00
Chloe Stefantsova 5cff200999 [cfe] Don't join unused same-name variables in pattern switch cases
Part of https://github.com/dart-lang/sdk/issues/49749

Change-Id: I245a68f48a217e26ad2e1a74a8996a8fef128da0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280421
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-02-06 10:24:35 +00:00
Martin Kustermann 214f44730a Use @Native instead of deprecated @FfiNative
Change-Id: I7eee5af952bc9625aded38f752bde442ecd76f27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279512
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-02-06 09:28:59 +00:00
Jens Johansen 76e2c48428 [parser] Support record type in variable pattern
When seing a '(' after a var/final in `parseVariablePattern` require a
type --- the only allowed thing is a record type, but we can't
generally allow for instance `() async =>` as a record type as that
normally means something else.

Fixes #51230

Bug: https://github.com/dart-lang/sdk/issues/51230
Change-Id: I2e4797595b545d4cb726e36ce4e70a4d775e7e25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280720
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-02-06 09:12:54 +00:00
Ahmed Ashour 5aa53088e5 [analyzer] report ASSIGNMENT_TO_FINAL_LOCAL
with `ForEachPartsWithIdentifier`

Bug: #49495
Change-Id: Ied4270e0c3032f4f1dfe30989a841fafdde9900d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280723
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-02-04 02:03:28 +00:00
Anna Gringauze b6bcdeaa5f [dartdev] Fix webdev integration test
Closes: https://github.com/dart-lang/sdk/issues/51106
Closes: https://github.com/dart-lang/sdk/issues/51037
Change-Id: If88b3e800764dbf0be4e294dc996fa2bc74be1f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280561
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2023-02-04 01:05:45 +00:00
Dmitry Zhifarsky 9fb7ec56f9 [analyzer] visit top level variable declarations metadata in ToSourceVisitor
Bug: https://github.com/dart-lang/sdk/issues/51236
Change-Id: I98c6fa8c79fbdfa9d9247618ce2d6931265b4915
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280468
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-02-03 16:49:29 +00:00
Danny Tuppeny 232e4af9fc [analysis_server] Add semantic token for "Never" type
Fixes https://github.com/Dart-Code/Dart-Code/issues/4372.

Change-Id: I00e47212d93eaf2d529c744f09777555f881037e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280164
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-02-03 16:41:26 +00:00
Johnni Winther 10953e26ca [cfe] Add test for parenthesized variable names
Change-Id: I2d3964edde49c22d9916fe266ec32e1516dd4f6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280721
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-02-03 12:47:31 +00:00