Commit graph

89752 commits

Author SHA1 Message Date
Konstantin Shcheglov 55e0784a62 Use pattern type schema for expression inference.
0277f03586

Change-Id: Ie305303ad85c0c7c920f9a28f4357abd9a02de3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281580
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-02-08 17:15:39 +00:00
Ryan Macnak e8842d862c [vm] Use atomics when setting RegExp bytecode.
TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/51305
Change-Id: I3e93716d31809be76a4017db68557a9b7263d2f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281560
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-02-08 17:07:43 +00:00
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
William Hesse d5202981b0 Update changelog with 2.19.1 and 2.19.2 hotfix release notes
Change-Id: I1ab6cdb8c305aaee492a26dfffcd013709a484f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281680
Reviewed-by: Kevin Chisholm <kevinjchisholm@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2023-02-08 14:33:50 +00:00
Martin Kustermann 404b71b2c5 [gardening] Fix null-save vm/dart/spawn_shutdown_test to not have compile-time error
TEST=Make vm/dart/spawn_shutdown_test run

Change-Id: Iaf5785f43918b2428a9810320677a9d1309fca6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281622
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-02-08 12:07:57 +00:00
Martin Kustermann 63b5f5d4b1 [vm] Ensure we copy shallow (but not deeply) immutable lists
The object graph copy code assumed kImmutableCid is used only for
list constants but it turns out our List.immutable([]) implementation
isn't using a wrapper-view, but instead a fixed-length immutable list as
with constants:

  factory List.unmodifiable(Iterable elements) {
    final result = new List<E>.from(elements, growable: false);
    return makeFixedListUnmodifiable(result);
  }

The list constants should already be handled via canonical bit.

Issue https://github.com/dart-lang/sdk/issues/51302

TEST=vm/dart{,_2}/isolates/regress_51302_test

Change-Id: I5924084ff004dc52bf675897455453d728484d1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281421
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-02-08 08:58:40 +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
Daco Harkes c95d1fc1ad [test/ffi] Fix test
Closes: https://github.com/dart-lang/sdk/issues/51301
Change-Id: I1dba254b0e396003448ba24c1c676f3dde04a861
Cq-Include-Trybots: luci.dart.try:vm-asan-linux-release-x64-try,vm-aot-asan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281422
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-02-08 08:44:57 +00:00
Devon Carew 1fc33f7c63 [deps] rev markdown and dartdoc
dartdoc:
494a6bed  2023-02-02  Sam Rawlins  Bump markdown dep to a pre-release of 7.0.0 (#3321)
ad6f1612  2023-02-02  Devon Carew  introduce an environmentProvider abstraction (#3324)
d0b73000  2023-02-02  Sam Rawlins  Prepare testing code for some upcoming Warnings (#3322)
936a7888  2023-02-01  Sam Rawlins  Add text about front-end manual testing (#3286)
cbee812d  2023-02-01  Sam Rawlins  Avoid renaming generator params (#3316)
bcaa0349  2023-02-01  Sam Rawlins  Privatize Library.sdkLib and move getClassByName (#3317)
af32def5  2023-01-31  dependabot[bot]  Bump github/codeql-action from 2.1.39 to 2.2.1 (#3313)
528e97da  2023-01-31  dependabot[bot]  Bump actions/cache from 3.2.3 to 3.2.4 (#3312)
54020672  2023-02-01  Parker Lougheed  Begin changelog for next release after 6.1.5 (#3315)

markdown:
f51c24c  2023-02-01  Zhiguang Chen  Prepend a line ending if the p tag is removed and there is an element before it in a *tight* list (#513)
dd3e3a1  2023-01-31  dependabot[bot]  Bump dart-lang/setup-dart from 1.3 to 1.4 (#510)
5f25fc9  2023-01-31  dependabot[bot]  Bump actions/checkout from 3.2.0 to 3.3.0 (#511)
54266b2  2023-01-31  Kevin Moore  Prepare to release v7.0.0 (#509)
d6ceff9  2023-01-31  Zhiguang Chen  Add line endings before HTML blocks (#508)
ccd3c8b  2023-01-29  Zhiguang Chen  Rewrite link reference definitions (#506)
e8f84dc  2023-01-24  Kevin Moore  Update GFM to 0.29.0.gfm.7 (#507)
93f67b0  2023-01-20  Zhiguang Chen  Add an `enableTagfilter` option to `HtmlRenderer` to eanble GFM `tagfilter` extension (#447)
d110770  2023-01-13  Zhiguang Chen  Rewrite SetextHeaderSyntax (#500)
c1b9bc6  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#504)
3e78c08  2023-01-01  dependabot[bot]  Bump actions/checkout from 3.0.2 to 3.2.0 (#501)
417747f  2022-12-15  Zhiguang Chen  Refactor list syntax (#499)
30ec05f  2022-11-29  Zhiguang Chen  Do not escape single quote(apostrophe) inside code (#498)
c3d1136  2022-11-29  Zhiguang Chen  introduce a Line class (#494)
Change-Id: I9d971b927b72500ab84cce461a60fe1a86818e2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281543
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2023-02-08 01:20:08 +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
Ryan Macnak e8b6c8a44f Reland "[build] Make build_analyze_snapshot consistent between the host and target toolchains."
Also create this target for Fuchsia, which like Linux and Android uses ELF.

Bug: https://github.com/dart-lang/sdk/issues/51242
Change-Id: I8e991d361b5defaa52b62a78d515a7639a6dfba0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281460
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-02-07 18:45:20 +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
Devon Carew 145b6c4a8c [deps] revert the recent roll of package:csslib
Change-Id: Ifa857de259f8ee4750bcdfa8c63f5c9a72322d1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281341
Reviewed-by: Oleh Prypin <oprypin@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2023-02-07 17:25:13 +00:00
Paul Berry a242875197 Test legacy flow analysis behaviour of case null.
I will be soon be implementing flow analysis for constant patterns.
This test is to ensure that when the language version doesn't include
support for patterns, we reproduce the legacy behaviour of `case null`
(which is not to draw any conclusions about type promotion or
reachability).

Bug: https://github.com/dart-lang/sdk/issues/50419
Change-Id: I2336a0e2cc30f5edf38d2b8da6bcd63fc62b30fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281282
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-02-07 17:10:10 +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
Sigurd Meldgaard 39136c1501 Bump pub to 048e3ad2b5e1b4ebe6883addbc95722be6904a7b
Changes:
```
> git log --format="%C(auto) %h %s" 0cbaf7a..048e3ad
 https://dart.googlesource.com/pub.git/+/048e3ad2 Add a spinner while validating before publishing (3776)
 https://dart.googlesource.com/pub.git/+/e5fdcf81 Fix terminal-detection logic for progress bar (3775)
 https://dart.googlesource.com/pub.git/+/16a79e2a Fix `global deactivate` on case-insensitive but case-preserving file systems (3774)
 https://dart.googlesource.com/pub.git/+/7493fad6 Updated documentation on entrypoint.acquireDependencies (3771)
 https://dart.googlesource.com/pub.git/+/faf9fa7e Info when publishing <3.0.0 constraint that is interpreted as <4.0.0 (3752)
 https://dart.googlesource.com/pub.git/+/bfaf3585 Validate package name in `pub global activate` (3735)
 https://dart.googlesource.com/pub.git/+/e84eefea Verify token characters when added and when used (3732)
 https://dart.googlesource.com/pub.git/+/60576f89 Correct spelling of 'publishing' (3767)
 https://dart.googlesource.com/pub.git/+/cb2f4b34 Bump actions/checkout from 3.2.0 to 3.3.0 (3763)
 https://dart.googlesource.com/pub.git/+/fc06561d Bump dart-lang/setup-dart from 1.3 to 1.4 (3764)
 https://dart.googlesource.com/pub.git/+/c6af8ff0 `dart pub remove`: Remove top-level key if empty after operation. (3758)
 https://dart.googlesource.com/pub.git/+/37692d8d Stop using always_throws (3765)
 https://dart.googlesource.com/pub.git/+/3ce46a32 Normalize pub.dartlang.org to pub.dev when reading lockfile (3754)
 https://dart.googlesource.com/pub.git/+/ab86f1e0 Add missing space in directory help text (3756)
 https://dart.googlesource.com/pub.git/+/14b13103 Fix `outdated`s handling of non-existent packages (3751)
 https://dart.googlesource.com/pub.git/+/56be1ca4 Fix typos in `dart pub add --help` (3750)
 https://dart.googlesource.com/pub.git/+/f698c43d Merge pull request 3746 from dart-lang/cherry_pick_conditional_sdk_rewrite
 https://dart.googlesource.com/pub.git/+/1bfb295d Merge branch 'master' into cherry_pick_conditional_sdk_rewrite
 https://dart.googlesource.com/pub.git/+/20f7daa9 Validate files don't differ in case only (3740)
 https://dart.googlesource.com/pub.git/+/9f41ae10 Only rewrite sdk constraints after dart 3
 https://dart.googlesource.com/pub.git/+/ea11b0d2 Only rewrite sdk constraints after dart 3 (3739)
 https://dart.googlesource.com/pub.git/+/12a2af4d Add and enforce require_trailing_commas (3728)
 https://dart.googlesource.com/pub.git/+/27c5cbd5 Only output errors during implicit resolution (3689)
 https://dart.googlesource.com/pub.git/+/e51b160b Remove features for migrating to null safety (3713)
 https://dart.googlesource.com/pub.git/+/f3cf3ac9 Add dependency kind information to `outdated --json` (3714)
 https://dart.googlesource.com/pub.git/+/0ee46ee0 Don't warn about overrides (3684)

```

Diff: https://dart.googlesource.com/pub.git/+/0cbaf7a2fb8c8ca543c6f222bf25d5f5c63abbf3..048e3ad2b5e1b4ebe6883addbc95722be6904a7b/
Change-Id: I9558072f3057c028f94c786f1dcdd8f48f42f39b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281400
Reviewed-by: Sarah Zakarias <zarah@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
2023-02-07 15:01:53 +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
William Hesse b5302e52d0 Revert "[build] Make build_analyze_snapshot consistent between the host and target toolchains."
This reverts commit 881825980e.

Reason for revert: The Fuchsia build of Flutter engine is broken by this change, since it uses the analyze_snapshot target.

Original change's description:
> [build] Make `build_analyze_snapshot` consistent between the host and target toolchains.
>
> Bug: https://github.com/dart-lang/sdk/issues/51242
> Change-Id: I7a0ad1f0bc94c4593412945e4887f9045693fd40
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280782
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,dacoharkes@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I3f069274fdef9366fea347ae5f452d2eb2267f70
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/51242
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281423
Commit-Queue: William Hesse <whesse@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Auto-Submit: William Hesse <whesse@google.com>
2023-02-07 14:33:57 +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
Alexander Thomas 04b01af929 [infra] Run weak mode on fewer VM builders
Change-Id: Idde9540266d33d758fa832845e4900aa8daf63d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281181
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-02-07 12:07:47 +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
Kallen Tu 9c86cb80bb [tests] Update language tests with base/final subtyping loophole fixed and a few enum tests.
Change-Id: Id30bbdc4b6eedf0751f725024acbed812a07a4fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280860
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-02-07 03:01:27 +00:00
Devon Carew 059634a18d [deps] sse, stack_trace, stream_channel, string_scanner, sync_http, term_glyph, test, test_descriptor, test_process, test_reflective_loader, typed_data, usage, vector_math, watcher, web_components, web_socket_channel, webdev, webdriver, webkit_inspection_protocol, yaml, yaml_edit
Change-Id: I8b34b03b9666d4513e11bae387b57af187ba2ca9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281281
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-02-07 01:44:33 +00:00
Devon Carew 2e90d39487 [deps] ffi_rev, file_rev, fixnum_rev, glob_rev, html_rev, http_rev, http_multi_server_rev, http_parser_rev, intl_rev, json_rpc_2_rev, logging_rev, matcher_rev, mime_rev, package_config_rev, path_rev, pool_rev, protobuf_rev, pub_semver_rev, shelf_rev, source_map_stack_trace_rev, source_maps_rev, source_span_rev
Change-Id: I4b806532e30a6f0617add767da2556972ca6cea9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281280
Auto-Submit: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-02-07 00:33:33 +00:00