Commit Graph

6523 Commits

Author SHA1 Message Date
Martin Kustermann 226a667ef9 [dart2wasm] Add const bool.fromEnvironment('dart.tool.dart2wasm.minify')
We add the `dart.tool.dart2wasm.minify` environment define (analogous to
how dart2js exposes `dart.tool.dart2js.minify`).

We make `package:expect/variations.dart` then expose to tests what
guarantees they can assume, namely

   * `readableTypeStrings`
   * `preciseErrorsWithDetails`

Change-Id: I43da09ed924ca9137721f4d70b7a494e01bf36e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430680
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2025-05-23 01:26:38 -07:00
Chloe Stefantsova 617d0a8e96 [model] Remove more nullability-related assignability error messages
This is a preparation for removing the subtype checking procedure that
ignores the nullability in the input types.

Change-Id: I3c1db55abde0433e9059d949f1c98aaeb61e210c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428980
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-05-19 00:18:57 -07:00
Paul Berry 929d058a1e Fix typo in demotion_and_type_of_interest_promotion_test.dart
Thanks to Lasse for pointing this out (see
https://dart-review.googlesource.com/c/sdk/+/427920/comment/0c3c5efc_f0a11a0f/).

Change-Id: Iea6dafd067d95651b9b7b80b5cff3979c1fd9989
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428843
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
2025-05-16 01:04:31 -07:00
Kallen Tu ecc6b93abd [cfe/analyzer] Dot shorthands: Abstract constructors can't be instantiated or torn off.
Adding a few errors on when we instantiate or tear off abstract constructors. Should be parallel to how we currently check for these errors in the CFE and analyzer.

Follow up to https://dart-review.googlesource.com/c/sdk/+/426682

Language test added, co19 test passing, and unit tests added.

Bug: https://github.com/dart-lang/sdk/issues/59758, https://github.com/dart-lang/sdk/issues/59835
Change-Id: I9b34e5f960856ce50aa969ca27e56907ae3a2a8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428201
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-13 10:10:51 -07:00
Paul Berry 6cea1790bd [flow analysis] Fix invalid type of interest promotion.
This change closes a loophole whereby it was possible for "type of
interest" promotion to promote to a type that was not a subtype of the
declared type.

I've gone ahead and included more extensive tests (both in unit test
and language test form) of demotion and type of interest promotion, to
try to make sure there aren't other loopholes.

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

Bug: https://github.com/dart-lang/sdk/issues/60620
Change-Id: Ifef04cde6fda2aee80ec002c7ca04f2be6cff987
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427920
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-13 06:10:25 -07:00
Paul Berry 7436b97ba4 [flow analysis] Allow non-cascaded field accesses to participate in field promotion.
The way this is accomplished is that in
`_FlowAnalysisImpl.nullAwareAccess_rightBegin`, any expression
reference associated with the target of the null-aware access is
restored, and the corresponding SSA node is associated with the guard
variable (if any). These changes ensure that if the null-aware access
is a property get, the subsequent call to `propertyGet` will pick up
the appropriate SSA node, so it will be able to locate the promotion
key for the property.

This functionality is only enabled when the language feature
`sound-flow-analysis` is enabled.

To prevent test regressions, a few related changes need to be made at
the same time:

- `_FlowAnalysisImpl.nullAwareAccess_end` is changed so that it clears
  any expression info or expression reference that was associated with
  the null-aware access expression. This prevents flow analysis
  information from being erroneously propagated out of a null-aware
  expression, which would have led to assertion failures when
  analyzing null-aware expressions inside of conditional
  expressions. This wasn't previously a problem because the expression
  reference used to be consumed by
  `_FlowAnalysisImpl.nullAwareAccess_rightBegin`, preventing further
  expression references and expression infos from being recorded
  further along in the null-aware access.

- The test framework in `mini_ast.dart` is fixed so that `!` is
  considered to participate in null shorting. This was a bug in the
  test framework that wasn't previously caught because it happened not
  to produce any test failures.

- The analyzer's method `PostfixExpressionResolver._resolveNullCheck`
  is changed so that it calls `nonNullAssert_end` before terminating
  null-aware access. Previously, the order was swapped, causing
  `nullAwareAccess_end` to be called before `nonNullAssert_end` when
  analyzing expressions like `a?.b!`. This used to be benign, but now
  that non-cascaded field accesses participate in field promotion,
  flow analysis needs the methods to be called in the correct order.

Fixes https://github.com/dart-lang/language/issues/4344.

Bug: https://github.com/dart-lang/language/issues/4344
Change-Id: I523be1b4be1af3f68654a745187a546728c878fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427820
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-12 08:25:20 -07:00
Paul Berry a757d2af41 Enable sound-flow-analysis for Dart 3.9.
Bug: https://github.com/dart-lang/sdk/issues/60438
Change-Id: I908d4e4a9143142281d8198870f40eba6cf6f67f
Tested: trybots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427500
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-09 14:50:26 -07:00
Stephen Adams a42401ab3e [dart2js] Remove checks to support migration with mixed null safety
`_potentiallyAssertNotNull` would insert null checks to catch issues
from mixing libraries sound and unsound null safety. The null checks
are now always optimized away so we might as well never insert them.

Bug: #60327
Change-Id: I092a4fb336e46bf33b9b3cd9867dd7b6d8f9c65e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427569
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2025-05-09 14:41:52 -07:00
Kallen Tu 29bc21c6d7 [analyzer] Dot shorthands: Add DotShorthandMixin to PostfixExpression to handle null-assert expressions.
The parser now handles the `!` operator which wouldn't be captured originally because we are parsing the shorthand with SELECTOR_PRECEDENCE.

Added a language test since no tests currently cover the usage of `!` and a few unit tests.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I66bdcc9a083c98d91b16d3ce8c952b8d4010ecd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425155
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-09 09:57:28 -07:00
Kallen Tu f6063e52f6 [analyzer] Dot shorthands: Error - constructors with type parameters.
Add `WRONG_NUMBER_OF_TYPE_ARGUMENTS_DOT_SHORTHAND_CONSTRUCTOR` for dot shorthand constructor invocations with type parameters.

Unit tests added and co19 tests + language tests such as `type_parameter_error_test.dart`.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: Ie8314f1678248f168744646dc0c3d2622cf61551
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426283
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-07 16:27:01 -07:00
Paul Berry c3e91333b6 Test interactions between null-aware accesses and field promotion.
As discussed in https://github.com/dart-lang/language/issues/4344, the
current implementation has some inconsistencies in how null-aware
accesses interact with field promotion. I intend to fix these
inconsistencies as part of the `sound-flow-analysis` language feature.

In this CL, I'm adding a regression test of the behavior that's
currently implemented (as of Dart 3.8), to help me make sure that when
I implement the new behavior, the changes will only take effect when
`sound-flow-analysis` is enabled.

Bug: https://github.com/dart-lang/language/issues/4344
Change-Id: If52a0ad044399904e3389af2130ca802efdd7058
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425922
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-05-05 06:59:41 -07:00
Nicholas Shahan 010a4b8227 [tests] Add regression test for dartbug.com/60643
Change-Id: I71d506e8cb7708478466b2162ccc40f0682f308c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425941
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2025-05-02 16:57:28 -07:00
Kallen Tu 73d6821a81 [analyzer] Dot shorthands: Report error when type arguments are not assignable.
This is a bug fix of the current implementation of dot shorthands type argument resolution. We want to make sure we're doing inference with the proper context type given at that point (with the element based on the dot shorthand context type we've saved).

Then I made sure there was proper argument checking, not just for `FunctionExpressionInvocation`s, but with `DotShorthandInvocation`s as well.

Tested with unit tests and language tests.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I795046502214628389c6471e9424aca7152657e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425780
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-02 09:28:52 -07:00
Robert Nystrom c9d54c12f6 Reformat tests/language/s** using 3.8 style.
Change-Id: I3c5cfbc1bc5e41d2ef1598427067dea00f9f42b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425403
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2025-05-02 04:46:00 -07:00
Robert Nystrom 200e0c83bd Reformat tests/language/r** using the 3.8 style.
Change-Id: Ibfa8df8eb3cdeec9afd45fa8448a7186869ae2c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425345
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2025-05-02 04:45:20 -07:00
Robert Nystrom 1ba6da2d08 Reformat tests/language/t** using 3.8 style.
Change-Id: I9627ebe0aa4d51d053a8dd1bd85873ba72e8e03c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425325
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2025-05-02 04:28:39 -07:00
Robert Nystrom cf4813a6cc Reformat tests/language/u** using 3.8 style.
Change-Id: I0618aa2abf0cd541dad70a77430a2745340f485a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425405
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2025-05-02 04:26:26 -07:00
Robert Nystrom 33798260d6 Reformat tests/language/v-z* using 3.8 style.
Change-Id: I781aabc6acc4f0341659380ed6cd169d66edce4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425346
Commit-Queue: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2025-05-02 04:14:03 -07:00
Kallen Tu 87b118b48c [analyzer] Dot shorthands: Error when resolving a dot shorthand invocation.
Added error code `DOT_SHORTHAND_UNDEFINED_INVOCATION` for when we are unable to resolve a dot shorthand invocation with a given context type and member name.

New unit tests and multiple co19/language tests passing.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I74fc053d668496539d88bee7d6eeee12acd9b710
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425145
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-01 14:15:30 -07:00
Kallen Tu fa486592bf [tests] Dot shorthands: Update bad language tests.
Updating some `??` tests to make them emit the correct warnings.
Removed an expected error where there wasn't one.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I8a1282e01ece6f3fd776eb06bcbb2cd7a1f8ed2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425587
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-01 09:59:01 -07:00
Kallen Tu c5116b420d [analyzer] Dot shorthands: Error - unable to resolve a dot shorthand property access.
Added `DOT_SHORTHAND_MISSING_CONTEXT` error code for when we don't find a valid context type to resolve the dot shorthand head with. `DOT_SHORTHAND_UNDEFINED_GETTER` is used for being unable to find a static getter or field with a certain context type and name.

Unit tests added and a few language error + co19 tests passing (eg `simple_identifier_extends_error_test`).

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: Ic515b57dd0f4243b049e02bd58b694a500d57975
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425181
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-04-30 12:25:04 -07:00
Robert Nystrom 361cf93984 Reformat tests/language/a-e using 3.8 style.
Change-Id: I5cfab9212bb78809967de323b60ebb06913b84d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425149
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2025-04-29 07:38:43 -07:00
Robert Nystrom a02d5bb211 Reformat tests/language/f-l using the 3.8 style.
Change-Id: I7dafd578cf8da38616ae25e5ce8dbbc7e3213014
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425185
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2025-04-29 07:37:05 -07:00
Robert Nystrom 159de518e2 Reformat tests/language/m-p using the 3.8 style.
Change-Id: I28f61e1e85408acc5403bfe95f360df4c7cb5ece
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425151
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2025-04-29 07:30:40 -07:00
Kallen Tu 9c3f9b6eaf [tests] Dot shorthands: Add language test for issue 60590.
User mmcdon20 filed an issue on these failing instances (top-level, initializers, initializer lists etc) and I want to make sure we capture these tests in a language test to make sure we don't have any regressions.

Bug: https://github.com/dart-lang/sdk/issues/60590, https://github.com/dart-lang/sdk/issues/57038
Change-Id: I1fe34bbf7f63ae95b75ebaf442107272f1ebfc4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424660
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-04-25 18:28:59 -07:00
Kallen Tu 7368e2c2a2 [tests] Dot shorthands: == and parenthesized expression tests.
A few extra tests for parenthesized dot shorthands on the RHS of an == or !=.

Bug: https://github.com/dart-lang/sdk/issues/57038
Change-Id: I2400247ea7017feff676090c5131822e0b17d5e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424680
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-04-25 17:51:20 -07:00
Kallen Tu 4ddb83ea9b [parser] Dot shorthands: Remove synthetic token in parser.
Context:
A while back, I inserted a synthetic token in the parser to allow us to parse without crashing the analyzer while I worked on the CFE. Now that both implementations are up and working, we can remove this synthetic token and allow the parser to parse as if we had enabled dot shorthands by default, and produce an error if the experiment isn't enabled.

This change allows a bunch of different language tests to start passing since they were blocked on the weird synthetic token messing up the parsing stream.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I792e3b917a76241b04ee708de06f670bbde64036
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423563
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-04-24 13:38:48 -07:00
Paul Berry 8f723eca90 [sound flow analysis] Language tests.
The tests that don't end in `_disabled_test.dart` exercise all the new
behaviors introduced with the `sound-flow-analysis` feature. The tests
that _do_ end in `_disabled_test.dart` verify that when the language
version is 3.8, the old behavior of flow analysis is preserved.

For the sake of thoroughness, I've also elected to include tests for a
few behaviors that aren't new, just because they seem logically
related to the new behaviors (for example, in the tests for the `==`
and `!=` operator, I've included a test that `null == null` is known
to evaluate to `true`, even though this behavior existed even before
the `sound-flow-analysis` feature was implemented). These tests are
marked with the comment "(this behavior predates sound-flow-analysis)"
in the `_disabled_test.dart` files.

Bug: https://github.com/dart-lang/sdk/issues/60438
Change-Id: If2895355bb1a2eeb2415a5a1012d73ae87c244dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423040
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-04-22 10:37:00 -07:00
Kallen Tu 3dd7e22739 [analyzer] Dot shorthands: Resolve DotShorthandPropertyAccess.
Allows the resolution of `.new` constructor references and static property accesses, using the existing `PropertyElementResolver` resolution logic.

Testing includes an AST builder test, and the `DotShorthandPropertyAccess` resolution tests. Some property access language tests are now passing.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: Idb576ef7fa0866bc4b2d155bbf867886ae2b4df6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421964
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-04-15 10:25:00 -07:00
Johnni Winther 0dde212150 [cfe] Add LookupResult
This replaces the individual lookups of getables and setables in LookupScope and NameSpace with single lookup that returns a LookupResult holding both the getable and the setable. This prepares for having getter/setter pairs in the same SourcePropertyBuilder and avoids the need for AccessErrorBuilder for handling lookups of getters where only setters exist and vice versa.

Change-Id: I2b1e2477ed43506d9f94c48acd4b44277b490540
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420080
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-08 03:49:31 -07:00
Stephen Adams 4ce96e92b6 Add test for #60409
Bug: #60409
Change-Id: I896d225f078e7a2f816d02c61c5050eb6affa470
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418502
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-04-06 10:39:00 -07:00
Kallen Tu d3a0c152e4 [cfe] Dot Shorthands: Handle constructor tearoffs.
This CL adds support for constructor tearoffs in dot shorthands. If there's any type parameters on the tearoff and it's a constructor, we produce an error.

I also updated the expectations of existing tests due to an early return of `InvalidExpression`s and added language + cfe tests for the new behavior.

This CL fixes the following co19 tests and is a follow up to https://github.com/dart-lang/co19/issues/3122
co19/LanguageFeatures/Static-access-shorthand/constant_expression_A03_t01
co19/LanguageFeatures/Static-access-shorthand/constant_expression_A04_t01
co19/LanguageFeatures/Static-access-shorthand/semantics_A05_t01
co19/LanguageFeatures/Static-access-shorthand/constant_expression_A03_t02

Bug: https://github.com/dart-lang/sdk/issues/59758, https://github.com/dart-lang/co19/issues/3122
Change-Id: I1ea837342ad818cd3b1de9e422065f42e8a61d6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419782
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-04-04 15:29:09 -07:00
MarkZ 23cefd8aa9 [ddc] Adding support for hot reloaded super getters.
This removes the 'bind' and 'bindCall' methods in our runtime in favor of extending 'tearoff' to support their behavior. Also introduces 'superTearoff' for invoking torn off super members late.

Change-Id: I52ab797558a225c57cc2c6197c7b1bfa7f05a3c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416763
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2025-04-04 11:17:56 -07:00
Kallen Tu 59acc56966 [cfe] Dot shorthands: Static invocations are inferred.
Similar to constructor invocations, we infer the type parameters for the dot shorthand static member that we find.

Added language + cfe tests for this case.

This CL is a follow up to: https://dart-review.googlesource.com/c/sdk/+/417960/comment/90f32aed_8d1f6c01/

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I96666ba9faa6ffaf42bd46e4d39175b88f7a353d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420283
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-04-04 10:47:39 -07:00
Kallen Tu a94645962e [cfe] Dot shorthands: Constructor type parameters are inferred in the empty context.
Fixes https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Static-access-shorthand/type_inference_A07_t01.dart and https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Static-access-shorthand/type_inference_A07_t02.dart.

This CL changes the following behaviour according to the spec -- In case of a constructor invocation, the shorthand expression is inferred in the empty context.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: Ia849888f1a810df7390a35e454a09f3fed458849
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417960
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-04-02 12:44:23 -07:00
Ömer Ağacan 68fd76fa68 [dart2wasm] Special case async functions with simple bodies
When an async function directly returns a `const` value, a basic
literal, or implicit `null` (empty body), omit the state machine loop
and exception handling.

See the new test for the cases this simplifies.

Issue: https://github.com/dart-lang/sdk/issues/60433
Change-Id: I25c25cb42c02cc3a9155e01ce205f63b567a1008
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419840
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-04-02 05:40:44 -07:00
Ömer Ağacan 93df675c5e [dart2wasm] Implement a workaround for front-end bug #60375
Issue: https://github.com/dart-lang/sdk/issues/60375
Change-Id: I6441c8b0c3cf94c9b33facc73ccf7bf8bba111d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419160
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2025-03-31 05:48:31 -07:00
Kallen Tu af51a0210b [cfe] Disallow '.new<int>' and type parameters on constructors for dot shorthands.
Adds errors for this part of the spec behaviour: `.new<typeArgs> and .new<typeArgs>(args) will always be compile-time errors because .new denotes a constructor which is not generic`

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I76074d2314f40f60015324d4b01ece7477a8ffb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417880
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-03-27 12:15:57 -07:00
Kallen Tu 1d99738b04 [cfe] Add support for 'call()' methods in dot shorthands.
Any dot shorthand code in the form of `.id()` where `id` is a field or getter should resolve to the `call` method in the declaration of the type of `id`.

Normal static invocations already do this, and this CL adds the extra bit of `call()` resolution to the dot shorthands feature.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: Ie8a22f251c3c80443e27d9fb307e7ef6b495315e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418141
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-03-27 09:05:46 -07:00
Kallen Tu c5133720b6 [tests] Dot Shorthands: .call() tests.
Adding tests for calling .call() on the dot shorthand getters/fields.

Bug: https://github.com/dart-lang/sdk/issues/57038
Change-Id: Ibdacd2bb9feba617f96996dd467328dbdb55c7b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417904
Reviewed-by: Erik Ernst <eernst@google.com>
2025-03-26 10:19:51 -07:00
Kallen Tu 656680ea09 [tests] Dot shorthands: CFE has no warning for if-null tests.
These warnings are only produced on the analyzer. Removing the CFE expectation for this.

Bug: https://github.com/dart-lang/sdk/issues/57038
Change-Id: I2eb22251a6247b633c0481ab6409723beb371a3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417881
Reviewed-by: Erik Ernst <eernst@google.com>
2025-03-26 10:19:35 -07:00
Kallen Tu ab778ef480 [cfe] Dot shorthands - Errors for invocations.
Adds `DotShorthandsUndefinedInvocation` error to handle unresolved method or constructor invocations.

Updates test expectations.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I004f989e2d6f460892964106ad72861fd3e49a5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417084
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-03-25 08:28:24 -07:00
Kallen Tu caa192d24c [cfe] Dot Shorthands - Errors for getters and fields.
This CL adds two errors - 1 for having an invalid context type for resolving a dot shorthand and 1 for not finding a static getter/field in the declaration provided.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I9cc473adf82ca1f74f2370136ac8eec5e97fb23e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416881
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-03-25 07:29:02 -07:00
Ömer Ağacan 9369147acf [dart2wasm] Use Symbol for function parameter names, minify symbols
With symbols as function parameter names we can improve the happy path
in function type and shape checks by using `identical` instead of
`compareTo` when comparing names.

We also minify constant symbols by giving them fresh indices (starting
from 0) and changing symbol values as base64 encoding of the indices.

Change-Id: I6457c1db94444e3d6e45c4f6dd832c6c73ff2844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414740
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2025-03-25 05:15:41 -07:00
Kallen Tu 7b3eb6773c [tests] Add more type parameter tests, add nested FutureOr and typedef tests.
Updating a few existing FutureOr and typedef tests.
Adding new type parameter tests.

Bug: https://github.com/dart-lang/sdk/issues/57038
Change-Id: Ic34b1ccbb97048d64afece6b925a3bf71d9f109e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417320
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-03-24 10:50:27 -07:00
Kallen Tu f61bba3fec [tests] Make sure generic types are explicit in nested test for dot shorthands.
We're missing some types here to make the tests work properly.

Bug: https://github.com/dart-lang/sdk/issues/57038
Change-Id: I207bbf15da4fad5da33f86c6efec10fcb6b4238c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416821
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-03-21 09:11:32 -07:00
Kallen Tu fbb00e5951 [cfe] Use findStaticMember instead of findInstanceMember for dot shorthands.
This CL avoids reusing `findInstanceMember` to find a static member for a given context. Implemented a new `findStaticMember` that handles resolving with the dot shorthand context.

All existing tests pass.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I71dfef451100ce77d5bd0d203129adbb281b6859
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-03-20 07:38:53 -07:00
Jens Johansen d3bbacfa9d [analyzer] Faster export scope calculation in bad cases
With the `big_chain_benchmark` for ImportExportCycle and
ImportCycleExportChain it scales a lot better. The other ones
(ImportCycle, ImportChain, ImportExportChain) doesn't change.


For ImportExportCycle, in AOT mode, before we got:

```
+------+-----------+------------+------------+
| Size |  Initial  | Completion | Fully done |
+------+-----------+------------+------------+
|   16 |   0.46673 |   0.169486 |   0.406448 |
|   32 |  0.875871 |   0.242876 |    0.85543 |
|   64 |  1.583077 |   0.465915 |   1.506953 |
|  128 |  3.198071 |   0.903894 |    3.09165 |
|  256 |  6.786677 |   2.149489 |   6.779569 |
|  512 | 17.346131 |    8.92149 |  17.971033 |
| 1024 | 63.358453 |  46.152089 |  65.401559 |
+------+-----------+------------+------------+
```


now instead we get:

```
+------+-----------+------------+------------+
| Size |  Initial  | Completion | Fully done |
+------+-----------+------------+------------+
|   16 |  0.474942 |   0.166857 |   0.411457 |
|   32 |  0.834925 |   0.243397 |    0.76843 |
|   64 |  1.608813 |   0.439885 |    1.53438 |
|  128 |  3.198453 |   0.805756 |   3.302559 |
|  256 |  6.347211 |   1.712426 |   6.165624 |
|  512 | 12.874747 |   3.551489 |    13.1461 |
| 1024 |  27.14403 |   7.844261 |   27.32785 |
+------+-----------+------------+------------+
```

An almost 6x improvement for completion and 2x+ improvement for both
initial analysis and analysing after the change.


For ImportCycleExportChain, in AOT mode, before we got:

```
+------+-----------+------------+------------+
| Size |  Initial  | Completion | Fully done |
+------+-----------+------------+------------+
|   16 |  0.454349 |   0.152505 |   0.400889 |
|   32 |  0.892146 |   0.302407 |    0.81263 |
|   64 |   1.67604 |   0.439954 |   1.517379 |
|  128 |  3.335087 |   0.907002 |   3.262481 |
|  256 |  6.378526 |   1.943725 |   6.292922 |
|  512 | 15.477861 |   6.461358 |  15.560008 |
| 1024 | 50.671197 |   33.14349 |  51.689455 |
+------+-----------+------------+------------+
```


now instead we get:

```
+------+-----------+------------+------------+
| Size |  Initial  | Completion | Fully done |
+------+-----------+------------+------------+
|   16 |  0.548357 |   0.166257 |   0.415632 |
|   32 |  0.906483 |   0.296618 |   0.910544 |
|   64 |  1.623723 |   0.464061 |   1.527888 |
|  128 |  3.067769 |   0.801507 |   2.927981 |
|  256 |  6.224551 |   1.596711 |   6.098531 |
|  512 | 12.941757 |   3.277487 |  12.345753 |
| 1024 | 25.870713 |   7.020787 |  25.760605 |
+------+-----------+------------+------------+
```

A ~4.7x improvement on completion and ~2x improvement for both initial
analysis and analysing after the change.

Change-Id: I052879c1695ad5f0aa63c2d96013a1e3eae96428
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413421
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-03-19 02:11:16 -07:00
Alexander Markov bbdb840023 [vm, dynamic_modules] Handle native stack overflow in the interpreter
TEST=corelib/error_stack_trace2_test

Change-Id: I337c15eecddccbe770158fa493bf296c171f9f08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415940
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-03-18 15:57:16 -07:00
Kallen Tu 7de867dd93 [cfe] Dot shorthands - FutureOr for invocations.
This CL implements `FutureOr` for static method invocations and constructors.

Note: `static_method_future_or_test` doesn't work due to unrelated reasons (initializers), but I corrected a typo anyways.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I77b97b0a9104fb0354ce1de39b619394f4477f32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414664
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-03-18 12:28:14 -07:00