Commit graph

44133 commits

Author SHA1 Message Date
Kallen Tu 291f6d803a [analyzer] Make sure the error check avoidance on InvalidTypes use hasInvalidType()
Avoid throwing `CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH` for any type of `InvalidType`s since we don't want to do any type checking if we don't actually know the types.

This is another fix for breakages in g3.

b/294003447

Change-Id: Id38de02cfd0317dc6771944bec0f54efb2614494
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317500
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-08-02 00:38:10 +00:00
Konstantin Shcheglov 9bf4af0049 Extension types. Report FINAL_NOT_INITIALIZED_CONSTRUCTOR and FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER.
Change-Id: Ifd18b5014b984a91a1f2a7ab662f937f9f6591ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317447
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-08-02 00:24:12 +00:00
Ben Konyi 5ef423d55c [ DDS ] Prepare for 2.9.4 release
Change-Id: I393ce964bce316592f78c0ea1de45ac1b34ddefd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317620
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
2023-08-01 22:59:17 +00:00
Kenzie Schmoll c96ea516f7 Serve devtools extension assets from devtools_server.
This change cannot be landed until a new version of devtools_shared is published and rolled into the SDK so that it can be depended upon here.

Change-Id: Ia7196fb8c12e980220ee2c2749a979f6359452a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305043
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2023-08-01 22:30:34 +00:00
Konstantin Shcheglov ddb4c28b40 Extension types. Tests for resolving method invocations.
Change-Id: Idbe4d172ec40152a5725dfc53acaeb6bb2980240
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317520
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-08-01 22:26:55 +00:00
Konstantin Shcheglov 08f2bc1e60 Extension type. Tests for resolving property access.
Change-Id: I536394862c1f92ca33fa368de9466d96b02d4d1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317580
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-08-01 21:59:48 +00:00
Sam Rawlins 5c9b4ed2cb [analyzer] Remove support for pre-const-update-2018 code
Dart 3's minimum language version is 2.12. google3's is 2.9.

Change-Id: Icd892b0fcec7f2ce9fa813a108519c0bbbd29a52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317040
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-08-01 21:31:52 +00:00
Kenzie Schmoll d792438829 Roll DevTools 2.26.1 into the SDK
Change-Id: I5206ced2deab27841f49c4f1272b0266ed14487b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317445
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-08-01 21:03:16 +00:00
Konstantin Shcheglov eb705b8636 Extension types. Resolve secondary constructors.
Change-Id: Ie0fd1ce1c368afe4d5c29f07b2674b208870daf9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317523
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-08-01 20:45:39 +00:00
Ryan Macnak 5e49ea5ad8 [vm, service] Fix discrepancy between VM generating kind _TypeParameters and service.md claiming the existence of kind TypeParameters.
Fix the service type `TypeParameters` to recognize it is a heap object.

Exhaustively test that the service client libraries can handle inflating all types produced by the VM. Compare vm/cc/PrintJSON, which exhaustively tests the VM can generate any type.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/52893
Change-Id: Id1f080656ef6e999e69f2ebb5b9961fa3b461e4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316862
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-08-01 20:34:21 +00:00
Konstantin Shcheglov c346b78f62 Extension types. Use 'Interface.redeclared' instead of 'overridden'.
Change-Id: Ibabd36e339d3f5258697985853c3d8d8fa3541a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317442
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-08-01 20:02:21 +00:00
Nate Biggs 2ec35b5761 [dart2js] Fix issue with non-async try/catch nested in catch block of async try/catch.
Fixes: 53082
Change-Id: Iadb11da5d6e71109682fc941f10e7373f70a1430
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317340
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-08-01 19:39:32 +00:00
Paul Berry 89738cff69 Flow analysis: remove reachable arg of _clone.
No functional change. By default, `_clone` re-uses the reachability of
`this`. The `reachable` argument allowed the caller to override that
default. However, the only call site that used it passed in
`this.reachable`, so there was no effect.

Change-Id: I2b08e29a724b35efc531f4bcfbc6ec4a2a2519d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317443
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-08-01 19:31:29 +00:00
Jake Macdonald 597444b54e add hasBody getter to FunctionDeclaration
Bug: https://github.com/dart-lang/language/issues/3078
Change-Id: I3b14d050062d0c2e90e6e0f5614dcc25e87a23fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316060
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-08-01 16:00:29 +00:00
Alexander Markov dc2abf0a80 [kernel] Add missing visitors for RecordNameGet.receiverType and RecordIndexGet.receiverType
Fixes https://github.com/dart-lang/sdk/issues/53070

Change-Id: If3a687626af6671b657eb034cf24685ba587f08f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317142
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-08-01 14:50:39 +00:00
Johnni Winther 5ea3b88932 [_js_interop] Use #type for interop message
The uses the #type handle to pass the DartType in the message rather
than using the toString() method which doesn't give the desired result.

Change-Id: Iac17507643a9932570d5975a106a3ededc03f58c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316585
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-08-01 11:12:19 +00:00
Johnni Winther de20ac1447 [cfe] Fix ExtensionType.==
DartType.== was declared abstract, expecting subtypes to call
the `equals` method, but this was accidentally omitted for
ExtensionType.

This CL moves the implementation to DartType.== since it was called
with the same arguments in all subtypes, thus ensuring that new
DartType classes will get the correct equals by default.

Closes #53046

Change-Id: Ieaaf33ecb569ea7361ac338066a3a5760391e424
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316583
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-08-01 11:04:22 +00:00
Ömer Sinan Ağacan 39fe8f458a [dart2wasm] Remove unnecessary initializer list collectContexts call
The `collectContexts(member)` already visits initializer lists when
visiting constructors, so no need to call it separately for
initializers.

Change-Id: Ida51a0e8c4003f19cd7b533a2847946926237bc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317101
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-08-01 10:53:09 +00:00
Johnni Winther a76f4d5c34 [cfe] Rename InlineClass to ExtensionTypeDeclaration
This renames InlineClass to ExtensionTypeDeclaration, and InlineType
to ExtensionType. Members of extension type declarations are called
extension type members instead of extension type declaration members
for "brevity".

TEST=existing

Change-Id: I91ed62533ddd345644492f04dc3310d007460288
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316780
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-08-01 09:04:38 +00:00
Danny Tuppeny d9363a6639 [analysis_server] Don't show expression snippets in argument names
Fixes https://github.com/Dart-Code/Dart-Code/issues/4635

Change-Id: I8e8addabc7bd601ad9a9abffb87f318243255932
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316222
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-31 20:31:23 +00:00
Danny Tuppeny abc712af72 [analysis_server] Show types when hovering over a wildcard variable pattern
Fixes https://github.com/Dart-Code/Dart-Code/issues/4640

Change-Id: Ide55831c0a7711d2bf2d389742a47cebfbe22f6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-31 20:26:22 +00:00
Sam Rawlins 1934efbffb Refactor comment reference parsing, away from stack.
Now that comment reference parsing is done entirely in ast_builder, we
can simplify the implementation.

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

Change-Id: I0650706dfe31542454c7bc9832ec6104c141bd5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316643
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-07-31 20:23:19 +00:00
Kallen Tu c9d69866eb [analyzer] Revert 'Fix broken code generators in g3.' and add new fix for code generators that result in InvalidTypes.
Reverting previous change since it does break some other parts of g3. Shortcircuiting the `??` isn't sufficient in some cases. So we attempt to fix it further downstream.

This change does a check for unresolved types and ignores the cast since we can't tell what type it is anyways. Similar to what we do with type parameters and when we don't know the type.

The generators in g3 seem to emit a lot more InvalidTypes and this is necessary to avoid the errors now that we propagate errors upwards.

b/293326927

Change-Id: I172980dfd3338f27d0a57e156b15dd937619ff73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316841
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-31 19:32:38 +00:00
Srujan Gaddam 7d6414a6d5 [dart:js_interop] Restrict external members from using type parameters that don't extend static interop types
Since external APIs can only use primitives and JS types in static interop,
we should require that all type parameters on static interop APIs extend
another static interop type. This is the minimum required to ensure all
type parameters can be erased to JSValue. This only affects dart:js_interop
users and replaces the previous type parameter static error check.

Change-Id: Ia546874da73c808aa25deb8d54d581db783987df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316140
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-07-31 17:40:56 +00:00
Danny Tuppeny 8abaa7b81b [analysis_server] Fix finding references for the offset between a type name and generic type parameters
Fixes https://github.com/Dart-Code/Dart-Code/issues/4668

Change-Id: Ibdb45b5c09ab8de0746239e351b5e581af4bb7df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-31 17:14:33 +00:00
Jonas Finnemann Jensen 1a4c889fbc Fix verify_diagnostics_test, #53020
Change-Id: Ida68ed3995c4db9be34fa0ce90b6683fc826f8a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315822
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-31 16:42:29 +00:00
Nicholas Shahan 5ed1a94ced [ddc] Update ddc stable targets to use new targets
- Updates test infra to use the assets built by the new "ddc" build
  targets.
- The old "dartdevc" targets are still present to avoid breaking 
  golem when this change lands.
- Old targets are still used when packaging assets for the SDK.
- Golem and the SDK packaging will be updated in following changes.

Change-Id: I1926e0c86833c812f5ed8355d7cd4df8740d79ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315224
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-07-31 16:06:07 +00:00
Joshua Litt 96d6c2e0d3 [wasm_builder] Refactor to a builder / built pattern.
This CL mostly just moves code around. There are three broad changes in this CL:
1) Reify the builder / built pattern that exists implicitly in the existing code. Builders now live in `src/builder`, while the built ir lives in `src/ir`.
2) Reify the module subsections.
3) `pkg/dart2wasm` has been updated to use the new API.

There is only one minor logic change in the entire CL, we now defer serialization of a module until the bytes are actually required, as opposed to serializing eagerly.

This change is designed to make the wasm_builder more robust. By clearly delineating which parts of the AST are mutable and which parts are immutable, then it should make it easier for users of the wasm_builder to avoid undefined behavior, i.e. holding on to something that can change.

Change-Id: I676107b867aa74fabf413108673e170126bdb5c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316280
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-07-31 15:27:58 +00:00
Sam Rawlins 415ff8ece8 [analyzer] Remove all checks for set-literal and extensions enablement
And using Future from dart:core, which was not enabled until Dart
2.1.0.

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

Change-Id: Id31d92007e685447ff217bdccf8161c8fd6ce6e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316863
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-30 00:12:59 +00:00
Konstantin Shcheglov 823f1583bf Extension types. Support in InheritanceManager3.
Change-Id: I49e30138f810247d1e20fa983f33f32d99a29c62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316845
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-29 18:10:24 +00:00
Paul Berry 2b8411f626 Enable language feature inference-update-2.
This language feature allows type promotion to apply to private final
fields, e.g.:

    class C {
      final int? _x;
      C(this._x);
    }
    f(C c) {
      if (c._x != null) {
        print(c._x.abs()); // (1)
      }
    }

Previously the line marked (1) would have needed to be written
`print(c._x!.abs());`.

Note that to ensure soundness, there are certain restrictions:

- Public fields don't undergo promotion (because a public field might
  be overridden by a class in some other library).

- Non-final fields don't undergo promotion (because a non-final field
  might be modified as a side effect of code executed between the type
  test and the field's usage).

- Fields that are forwarded to `noSuchMethod` in the same library
  don't undergo promotion (because there's no guarantee that
  `noSuchMethod` will return the same value on every invocation). For
  example:

    class C {
      final int? _x;
      C(this._x);
    }
    class D implements C {
      @override
      noSuchMethod(...) => ...;
    }
    f(C c) {
      if (c._x != null) {
        print(c._x.abs()); // ERROR: `c._x` might dispatch to
                           // `D.noSuchMethod`, in which case there's
                           // no guarantee that it will return a
                           // non-null value the second time it's
                           // invoked.
      }
    }

- If two classes define fields or getters of the same name, and
  promotion is not permitted for one of them, then it isn't permitted
  for the other. This is because there might be a class in some other
  library that's a subclass of both classes, causing a reference to
  one field or getter to dispatch to the other. For example:

    class C {
      final int? _x;
      C(this._x);
    }
    class D {
      int? get _x => ...;
    }
    f(C c) {
      if (c._x != null) {
        print(c._x.abs()); // ERROR: `c._x` might dispatch to `D._x`
                           // (e.g. because some library might declare
                           // `class E extends D implements C`), in
                           // which case there's no guarantee that it
                           // will return a non-null value the second
                           // time it's invoked.
      }
    }

Change-Id: Ib9183581aa0194377e38ab70d37c3e9f0bb57a75
Bug: https://github.com/dart-lang/language/issues/2020
Tested: TAP global presubmit
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314600
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-28 23:56:52 +00:00
Kallen Tu 19859a0f91 [analyzer] Add error for deferred constants in const constructors.
There's a false positive with the `prefer_const_constructors` lint where
deferred constant values in const constructors were not being reported
as an error.

This change adds the new error so that the lint doesn't fire.

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

Bug: https://github.com/dart-lang/sdk/issues/48991
Change-Id: I378093c02ec63e0c5eb5a1a8d80c1bbb0c88ba2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316842
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-07-28 23:47:35 +00:00
Jake Macdonald 91f389ed6a Drop use of package:_dart_internal in _fe_analyzer_shared
This is largely a copy of https://github.com/leafpetersen/cast, with some extra magic.

Change-Id: Iff92ac9a57b1cfbaa67fe15647aabb8858442b60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316880
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-07-28 22:36:44 +00:00
Konstantin Shcheglov 1c241a195a Extension types. Test building getter / setter elements.
Change-Id: Ie88d9eded5389c081104f07df65405b690d3a354
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316840
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-28 18:17:30 +00:00
Konstantin Shcheglov eb639c559b Extension types. Basic resolution.
Change-Id: I40f15cea81909c2b8dbe79990ee52abf0fc2e196
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316860
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-28 18:17:20 +00:00
Sam Rawlins b87dee93a7 [analyzer] Rename AnalysisOptions.hint to AnalysisOptions.warning
Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: I7050b4f758976ff555e43f219c6f5c2b0e8d362a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290903
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-28 15:51:05 +00:00
Konstantin Shcheglov b477c154a9 Extension types. Implement isNonNullable(), etc.
Change-Id: Icc6e4bc71e139d0a90c77fe437ec90b550a4bd2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316720
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-28 15:25:10 +00:00
Alexander Markov 6f8ddef40b [test_runner] Fix passing --suppress-core-dump to Fuchsia emulator
Previously, --suppress-core-dump option was inserted into the beginning
of the command line and was effectively passed to fssh, which
doesn't understand this option:

  ./third_party/fuchsia/sdk/linux/tools/x64/fssh --suppress-core-dump run fuchsia-pkg://fuchsia.com/dart_ffi_test_release#meta/fuchsia_ffi_test_component.cmx --sound-null-safety -Dtest_runner.configuration=vm-fuchsia-release-x64 --ignore-unrecognized-flags --packages=/pkg/data/.dart_tool/package_config.json --disable-dart-dev /pkg/data/tests/ffi/callback_unwind_error_test.dart

Instead, it should be passed as the first argument after 'run ...cmx':

  ./third_party/fuchsia/sdk/linux/tools/x64/fssh run fuchsia-pkg://fuchsia.com/dart_ffi_test_release#meta/fuchsia_ffi_test_component.cmx --suppress-core-dump --sound-null-safety -Dtest_runner.configuration=vm-fuchsia-release-x64 --ignore-unrecognized-flags --packages=/pkg/data/.dart_tool/package_config.json --disable-dart-dev /pkg/data/tests/ffi/callback_unwind_error_test.dart

TEST=ci
Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-x64-try
Change-Id: Id33a4c54478b872889dcdd7034e9dae6336a3ae8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316620
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: William Hesse <whesse@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2023-07-28 12:03:40 +00:00
Johnni Winther 4efcda0fd2 [cfe] Generate statements for trivial pattern assignments
Closes #52960

Change-Id: I868a7ef5867ad955072ae5425da82c007ca1d73c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315902
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-28 11:11:37 +00:00
Johnni Winther bbbf6b907a [cfe] Support extension types from dill
In response to https://github.com/dart-lang/sdk/issues/53036

Change-Id: I676f5086028b88023b37379d674d66a8908709e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316580
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-28 10:37:27 +00:00
Martin Kustermann 23109940e0 [vm] Separate for-snapshot vs embed-sources bools when compiling to kernel
Fixes https://github.com/dart-lang/sdk/issues/53010

TEST=Fixes vm/dart/regress_48523_test

Change-Id: I2066ffd250228c01bb7aa2de5d1d0362ba6f7071
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316581
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-07-28 10:01:53 +00:00
Srujan Gaddam 79df0b2789 [dart2wasm] Mark _typeArguments as synthetic
Fixes b/293426600

This synthetic procedure is added on every class with type args.
Mark it as synthetic so the JS interop checks don't trigger on
it.

Change-Id: I5b04fe4340b409a4ab1eb5c32e37fe6ff37df4b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316702
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
2023-07-27 22:54:58 +00:00
Sigmund Cherem 862d974619 [modular_test] second attempt to fix shards.
Turns out the old code was also checking for the presence of the DEPS file.
This is not necessary, it was only done as a safeguard in case we had multiple
folders with the same name lying around. We could add DEPS to the set of files
sent to the shard, but that seems unnecesary here.

Fixes #53059

Change-Id: I83fc2569f42117c5fc4ea90c651cd7627a21a9ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316700
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2023-07-27 22:29:07 +00:00
Konstantin Shcheglov 5f4a6f4629 Extension types. Resolve field initializers and default values.
Change-Id: I72f5cc6ae8970bce7382ab8d8994e07c256c94e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316644
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-27 22:20:36 +00:00
Konstantin Shcheglov ec57086a04 Add visitExtensionTypeElement()
Change-Id: I1e4b9ed6c646640c4e8ad7b2b5223936605956e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316626
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-27 21:29:32 +00:00
Konstantin Shcheglov ff17bed0e6 Build superinterfaces for extension types.
Change-Id: I74743591947a5798b60770a7c202cecfc5098e46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316624
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-27 20:53:33 +00:00
Konstantin Shcheglov e623e291a7 Add TypeSystemImpl.isValidExtensionTypeSuperinterface()
Change-Id: Ic2d40f1faab9851b3f4f9ee7605dabf197dca433
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316640
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-27 19:29:22 +00:00
Sigmund Cherem 0a3ca5a098 [modular_test]: support running modular_test unit tests in shards.
The findRoot method made assumptions that were only true when running the
test in the main shard of our test runners. This caused a few tests to
start failing when sharding was enabled in:
089364baab

Fixes #53059

Change-Id: I32c59d6ae396fba5cbf19491eb17d7b90a7b8cd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316642
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2023-07-27 19:19:43 +00:00
Kallen Tu 13a986db82 [analyzer] Fix broken code generators in g3.
Some part of the code generators trigger the `??` RHS operand when there is an unresolved type on the LHS.

In the previous const evaluator prior to https://dart-review.googlesource.com/c/sdk/+/312347, errors triggered by unresolved types would be ignored. Now that we have specific unresolved constants, we need to short circuit the evaluation in some places.

Anyways, this change makes unresolved types return LHS early (they're represented by a `Null` state) until I can find a better fix for this.

b/293326927

Change-Id: Ifcbff9921e1d4a82dc24153b042eaaa862bcca68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316490
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-27 17:05:19 +00:00
Konstantin Shcheglov 293d32fe76 Share more code using TypeParameterizedElementMixin.
Change-Id: I47bdfac9befe020c1daef72aec299ad752710209
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316487
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-27 15:14:50 +00:00
Johnni Winther bf9ea56ff7 [kernel] Remove nodes used for the old 'extension-types' experiment
This removes ExtensionType, ExtensionTypeShowHideClause and
CallSiteAccessKind from package:kernel which where only used by the now
removed 'extension-types' experiment.

A follow-up CL will rename InlineClass/InlineType to
ExtensionTypeDeclaration/ExtensionType to match the names of the
Extension Type feature currently being implemented.

TEST=existing

Change-Id: I58d2e8b0a92ac61329ee161cc6884a2c0e6f87ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316420
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-07-27 10:47:08 +00:00
Johnni Winther 74fa24d4c0 [cfe,analyzer] Remove 'extension-types' experimental flag
This is not the flag you're looking for.

The 'extension-types' flag was used for an early experiment that is
not directly related to the Extension Types feature currently being
developed. The current feature uses the 'inline-class' flag.

Change-Id: Icbb6c3828c41e743e726161b17da4c7784a2c677
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316380
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-27 09:30:36 +00:00
Konstantin Shcheglov b42c27f2a2 Issue 53029. Include constant dependencies of map patterns.
Bug: https://github.com/dart-lang/sdk/issues/53029
Change-Id: I8d604a153452acee581f291f5806f88b4478fee0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316081
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-27 03:22:23 +00:00
Sam Rawlins cb93ac73fd Re-add applyToAnalysisOptions, needed by internal customer
b/293297223

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

Change-Id: I8303b14de17b695e835cf9f8018f08731b51ec35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316526
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-27 02:43:38 +00:00
Konstantin Shcheglov 88d84eb6f2 Remove ElementImpl.typeParameterContext, unused.
Change-Id: Idac59ddb6fa013ea1a01ff4cf16cd3df4b2cf672
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316489
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-27 02:21:30 +00:00
William Hesse 7d802ca199 Increase maximum sdk version constraint on dart_internal to 3.3.0
The dart_internal has a maximum sdk version constraint so it
can be deprecated and removed once it is no longer used.
Increasing it from <3.2.0 to <3.3.0.
The package is still used internally, and downloaded by Flutter
from pub.

Change-Id: I210ac7453950388544d03d768ad9261d51a7f060
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316540
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2023-07-27 00:29:42 +00:00
Liam Appelbe edeac698c2 [vm/ffi] Closure callbacks for async callbacks
This change is almost trivial. The closure is stored on the callback's
RawReceivePort, not in the VM. So we can basically just remove the CFE
check and it pretty much works. The only problem is that we can't set
function.FfiCallbackTarget anymore, so most of the CL is dealing with
that.

A few places were deciding whether an FFI trampoline was a call or a
callback based on whether function.FfiCallbackTarget() was null. But
now the target will be null for async callbacks. So instead I've added
a new value to the FfiCallbackKind enum (and renamed it), and changed
those checks.

Sync callback closures will be a separate CL, because they're more
complicated.

Bug: https://github.com/dart-lang/sdk/issues/52689
Change-Id: I8e5dfb557362e679f66195b735c3c382e6792840
TEST=async_void_function_callbacks_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316160
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-07-26 23:23:26 +00:00
Kallen Tu 946175cbd0 [analyzer] Add tests for the removal of 'A value of type 'Null' can't be assigned to a parameter' overreporting in the const evaluator.
The constant evaluator now handles invalid types better and won't overreport this nonsensical error.

Bug: https://github.com/dart-lang/sdk/issues/47603, https://github.com/dart-lang/sdk/issues/47351, https://github.com/dart-lang/sdk/issues/49389
Change-Id: I63c253d2177c2b8c259c364e83753653eac1cae0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312707
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-07-26 20:36:28 +00:00
Sam Rawlins 05f2b3222a [analyzer] Add extension-naming to our style doc
Change-Id: I454df164b2cede7c4ae7d6fdf541e67fdf7090da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316525
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-26 20:32:59 +00:00
Konstantin Shcheglov 4787a99ba0 Don't print 'shouldUseTypeForInitializerInference' when no initializer expression.
Change-Id: I73c7bc973d8cdfbcc6d63232a5c8eec0ac43fe76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316524
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-26 19:46:18 +00:00
Konstantin Shcheglov d02097bd1e Test for extension types with type parameters.
Change-Id: Ib0d406cd98116deea20eb402d113f3cd2b97504c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316482
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-26 18:45:41 +00:00
Konstantin Shcheglov c36ff43382 Parse and use 'const' keyword for extension types.
Change-Id: I331d57f46507981f8532d504211267316770f86b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316521
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-26 18:45:12 +00:00
Sam Rawlins 411cfeef13 Address feedback from cr/316340
Change-Id: I5fecdab01b9a2af385ecae72b00b076821b3a605
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316480
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-26 17:27:38 +00:00
Derek Xu 0ba8d4ef77 [VM/Debugger] Fix the behaviour of setting inline breakpoints in uncompiled functions
TEST=pkg/vm_service/test/column_breakpoint_test.dart, other debugger
tests in tryjobs

Fixes: https://github.com/dart-lang/sdk/issues/51563
Change-Id: I87ef7e52cfc7e922904b267b7eb74fc783214b44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316440
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-07-26 17:15:36 +00:00
Sam Rawlins a07f57c7a1 Split out 'analysis-options-application' code from verification code
Change-Id: Id3aab1ef4c91c2f4c59ca253acbc51b80d6409ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316340
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-26 16:24:37 +00:00
Kallen Tu 66df28dcc6 [analyzer] Remove unused ConstantEvaluationValidator.
ConstantEvaluationValidator and it's implementation is not used
anywhere in g3 nor in the sdk.

Change-Id: I7490501e2e55ac567a996af658bb09dd7c37c8df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316020
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-26 15:21:04 +00:00
Konstantin Shcheglov e6f9e58371 Basic building of ExtensionTypeElement(s).
Change-Id: I0489a5dde5afe244d8c4b58351b3ecac6315a790
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316080
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-26 15:10:09 +00:00
Ömer Sinan Ağacan dd712accf4 [dart2wasm] Test with d8 --wasm-final-types --wasm-disable-deprecated
Change-Id: Iba192eb02bb6163e95e55deb4c3912315b8b77ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316201
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-07-26 10:58:09 +00:00
Johnni Winther 53deaf0522 [parser] Support 'extension type const'
This adds parser support for the optional 'const' keyword in extension
type declaration. The token is passed on through the endPrimaryConstructor
listener call since it is used to make the primary constructor constant.

Change-Id: I518a8e397fb62272002c424e7b69affe6123f4af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316221
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-26 08:17:49 +00:00
Nate Biggs 4f03bd0c30 [dart2js] Defer loading of codegen results.
This was landed a while ago as https://dart-review.googlesource.com/c/sdk/+/254600. However, this had to be rolled back because at the time this increased memory usage for the emitter phase. This change prevented GC from cleaning up the byte arrays of the codegen serialized files which resulted in an increased max heap.

However, now that we map (rather than copy) files into memory, there is no overhead to keeping a reference to the codegen serialization files.

Thanks to recent improvements in the efficiency of deferred serialization this change seems to improve max memory usage by up to 1.2GB for the emitter phase. Avoiding caching results also helps in this regard, usage of the results is fairly localized.

Change-Id: I4d401a877cb74cbb36b511eb598a759fe300fd5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316180
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-07-26 02:23:40 +00:00
Kallen Tu ba005169c5 [analyzer] Initial refactor of _InstanceCreationEvaluator to return Constant value.
evaluateConstructorCall now returns a Constant, which means evaluation may be cut early in some places if there's an error. However, some code generators rely on _InstanceCreationEvaluator to complete, and so there's no _major_ changes to the design right now (and some small additions to avoid breaking many tests).

This CL is just the framework for the "return Constant" design and will be the base for reporting better errors in constructor invocations.

These changes already show that we cut some amount of over-reporting in our existing language and unit tests, which is a step in the right direction.

Bug: https://github.com/dart-lang/sdk/issues/47603, https://github.com/dart-lang/sdk/issues/47351, https://github.com/dart-lang/sdk/issues/49389

Change-Id: I5ba7f1282658884c18a32d5e98c7804bbfeac0f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312347
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-07-25 19:23:02 +00:00
Sam Rawlins 005f7e84c2 Add fix for unreachable_from_main
We have a fix to remove private declarations (classes, other elements, local variables, etc). No reason to not allow this for public elements in entry-point libraries.

Change-Id: Id4c0ef1b14658d701229ea71d25669982e98d6c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313291
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-25 17:59:02 +00:00
Konstantin Shcheglov 8b6074617a Tests for metadata in ExtensionTypeDeclaration.
Change-Id: Ie474674bfba980ad085620d731540f0018534ae6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316240
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-25 17:43:08 +00:00
Paul Berry 5a79f8a9f3 Unify "mini-ast" constructs for rest pattern elements.
Previously, in the "mini-ast" pseudo-language for shared flow analysis
and type analysis unit testing, there were two separate functions to
create a rest pattern (`...`):

- `listPatternRestElement` for creating a rest pattern for use in a
  list pattern

- `mapPatternRestElement` for creating a rest pattern for use in a map
  pattern

The latter is not allowed in Dart, but it's supported to allow for
better error recovery.

But having two functions wasn't necessary--the two functions did
exactly the same thing.

This CL simplifies things so that there is just a single function,
`restPattern`. It also renames the underlying representation class
from `RestPatternElement` to `RestPattern`, to match the nomenclature
in the patterns spec document.

Change-Id: Iecfe8c86f49161e0657cdab44f000f47c0e3c212
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315520
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-25 16:36:28 +00:00
Alexander Thomas a3d48885e7 [release] Bump version on main to 3.2
Tested: CQ
Change-Id: I16210697b47dd85aec8743b457e773b044cab81f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316200
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-07-25 15:12:49 +00:00
Joshua Litt d1660236f1 [wasm_builder] Defer encoding instructions until Module.encode.
This CL lays the foundation for allowing us to emit instructions without finalizing imports, which will in turn enable more flexibility in code generation. For example, we will no longer need to do a pre-code generation pass to collect imports. In addition, it will pave the way for other optimizations as suggested in the `TODO` at the top of `instructions.dart`.

Perhaps counter-intuitively, even without any optimizations, this doesn't seem to be a measurable regression:

Before:
  Completed compilation of dart2wasm-html-engine in 52652ms.
  Completed compilation of dart2wasm-html-html in 51827ms.
  Completed compilation of dart2wasm-html-ui in 20399ms.
  Completed compilation of dart2wasm-canvaskit-canvaskit in 32899ms.
  Completed compilation of dart2wasm-canvaskit-ui in 20695ms.
  Completed compilation of dart2wasm-skwasm-ui in 20319ms.

After:
  Completed compilation of dart2wasm-html-engine in 51476ms.
  Completed compilation of dart2wasm-html-html in 48845ms.
  Completed compilation of dart2wasm-html-ui in 19676ms.
  Completed compilation of dart2wasm-canvaskit-canvaskit in 31933ms.
  Completed compilation of dart2wasm-canvaskit-ui in 19733ms.
  Completed compilation of dart2wasm-skwasm-ui in 19962ms.

Change-Id: Ib3740f88db56070fc3ccdde484675267e4bf40c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315580
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-07-25 13:55:10 +00:00
Paul Berry 39e1357288 Add shared analysis testing infrastructure for map literals.
This change adds the functions `mapLiteral` and `mapEntry` to the
"mini-ast" representation used for unit testing shared flow analysis
and type analysis logic. These can be used to model map literals with
explicit type arguments. Set/map literals without explicit type
arguments are not supported yet.

These functions replace the old `inContextMapEntry` method, which was
an alternative way of testing the type analysis behavior of map
literal entries (and was not yet being used). The new approach is
better in that it allows the test cases to follow the structure of
actual Dart code (map entries inside map literals) rather than just
testing map entries in isolation.

Change-Id: I4bfd31b8fb2865f3d0892da0a47ee0bdacaf9250
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315225
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-25 13:49:06 +00:00
Johnni Winther 5833837622 [cfe] Add test for issue 43400
Closes #43400

Change-Id: Icdd968f1265d2cf0969027752b2cdb3d2f04050b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316220
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-25 13:42:59 +00:00
Johnni Winther 4d78361e8f [cfe] Handle absolute part/part-of uri with packages
Closes #52964

Change-Id: I787af659744be45df4221fcaefe2b524beb20776
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315403
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-25 11:42:58 +00:00
Chloe Stefantsova 2c86500e36 [cfe] Adjust nullability of UP of intersection type and another type
Closes https://github.com/dart-lang/sdk/issues/52993

Change-Id: Id7c18f98d2422264ca69e275505d4977b8b59a99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315900
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-07-25 10:12:58 +00:00
Johnni Winther 29ff51a008 [cfe] Add ExtensionTypeHierarchyNode(Builder)
This adds checks for conflicting supertypes and prepares for computation
of extension type members.

Change-Id: If997fe84bac929274a6014b315ecea4f3856eedd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315441
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-25 09:15:47 +00:00
Nicholas Shahan f4e949609c [ddc] Add new build targets for DDC assets
- Introduces a new output subdirectory `gen/utils/ddc` where the
  new build targets output files. This is intended to make the
  migration to the new assets easier since landing this change
  shouldn't immediately break any dependencies.
- Enables building the canary and stable assets at the same time.
- Changes more names in our workflow from "dartdevc" to "ddc".
- Updates the ddc-canary-linux-chrome and
  ddc-canary-linux-chrome-unsound configurations to use the
  new assets.

The new outputs appear in directories that are more consistently
named, (no more sound vs kernel confusion). They are named in
preparation for the eventual deletion of the unsound targets
without any lingering cruft to be cleaned up in the sound
directories.

The new structure is:

```
gen/utils/ddc/
           |- canary
           |  |- pkg
           |  |- sdk
           |- canary_unsound
           |  |- pkg
           |  |- sdk
           |- stable
           |  |- pkg
           |  |- sdk
           |- stable-unsound
              |- pkg
              |- sdk
```

The 'pkg' and 'sdk' directories all contain outputs with the same
files names, each compiled in the respective build modes
(sound/unsound and stable/canary).

Change-Id: I66822ebf03bba487b6d359a8e0aa818b9e7b6bef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313081
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-07-25 00:19:52 +00:00
Sam Rawlins 8e66248765 Refactor doc comment-parsing tests
I suspect we ought to just remove many/all of the remaining simpler parser tests. I glanced at a few, and they do not seem specific to analyzer, so their covered features should be covered by parser tests in _fe_analyzer_shared.

https://github.com/dart-lang/sdk/issues/50702

Change-Id: I0e524562f6584145db5e80a154e72ea66090d924
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316042
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-25 00:15:41 +00:00
MarkZ afefee3018 [ddc] Trust nullability of parameters in dart:_rti.
Improves performance of legacy mode apps in the new type system.

Change-Id: Ia884ea244741df5385271f43baa4125678b995ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315983
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-07-25 00:00:48 +00:00
Jake Macdonald e12698594c Move more macro apis to has* instead of is* nomenclature.
These are intended to be syntactic and not semantic in meaning, so I think has* is a better name.

Change-Id: Ia2a8a276c1057bde913eb755cc1a7a559d953774
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315960
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2023-07-24 20:51:38 +00:00
MarkZ 5831ed204f [ddc] Avoiding emitting legacy or mixed mode null checks for dart:_runtime and dart:_rti operations.
A side effect of DDC's new shared runtime ('dart:_rti') is that previously @notNull-annotated code paths were being extraneously null-checked. This is partly responsible for the slowdowns in some internal mixed-mode apps found in testing.

Change-Id: I3f619cfd23688f3eb4ada0079ad1664d39a7e010
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315640
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2023-07-24 20:06:43 +00:00
Kallen Tu 1740829f34 [analyzer] Remove unused methods in the constant evaluator.
Found some methods that weren't being referenced anywhere, or they
weren't cleaned up. Removing because it's just dead code.

Change-Id: Id344d2d7cedd87468255a33fea75bfda97d10cac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316000
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-07-24 19:44:19 +00:00
Ömer Sinan Ağacan 7fec037b6b [dart2wasm] Split more patch files into patch + implementation files
Following the refactoring we started in previous CLs, this splits string
and int patch files into (1) patch files that only patch and don't add
implementation classes (2) files for implementation classes (3) helpers.

Changes:

- `string_patch` is split into `string.dart` and `string_patch.dart`.

- VM's `integers_patch.dart` copied as `int_patch.dart` and updated.
  This was needed as `integers_patch` requires VM's library paths in
  imports.

  We needed to copy this file to be able to optimize based on
  dart2wasm's implementation classes. However in this CL we copy the
  file as-is and update import paths.

- VM's `string_buffer_patch.dart` copied to be able to use the string
  implementation classes from the new library.
  `string_buffer_create.dart` is merged ino `string_buffer_patch.dart`.

- `getHash` and `setHash` to set object identity moved to
  `object_helper.dart`, to be able to use in string implementations.

- Redundant `new` keywords in copied files removed.

One TODO added in `string_buffer_patch.dart` when allocating a new
string to the buffer:

    // _parts = _GrowableList.withCapacity(10)..add(str);
    // TODO(omersa): Uncomment the line above after moving list
    // implementations to a library.
    _parts = [str];

We can enable the old code again after moving list implementations to a
library.

Change-Id: Ice5dba40b3ba894797028987d4b42cb0c0f0c230
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315821
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-07-24 16:58:52 +00:00
Samuel Rawlins 008cb0bbc1 Revert "Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT"
This reverts commit a458bab09a.

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

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

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

Change-Id: Ib0c9afc4911efd620013896fb895ab7825c50aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315940
Commit-Queue: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-24 16:25:07 +00:00
Jake Macdonald 5220b9e5f7 Add Extension declaration introspection and extension macros
Bug: https://github.com/dart-lang/language/issues/3223
Change-Id: I43e0ea17ea1bf8dbb41ad899675ac25d26ca568f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315300
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2023-07-24 15:24:10 +00:00
Paul Berry 03a91b5d2a Simplify handling of variable expressions in shared analysis tests.
When using the "mini-ast" pseudo-language to write unit tests for the
flow analysis and type analysis logic in the `_fe_analyzer_shared`
package, it is no longer necessary to use `.expr` to turn a `Var` into
an `Expression`; this now happens automatically. The way this works
under the hood is that the `Var` and `Expression` classes implement
the `ProtoExpression` interface; constructs that expect expressions
are declared with input parameters of type `ProtoExpression`, and they
automatically convert to `Expression`s when necessary.

Change-Id: I85c493145c3fc41a5296c1807cd63fe1401672db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315247
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-24 15:03:19 +00:00
Konstantin Shcheglov 2d5dd229fe Add ExtensionTypeDeclaration, parse into it.
Change-Id: I5f7e8b074a137f6be86965509a47ce10c11e05e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315620
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-24 15:02:38 +00:00
Johnni Winther d9a1bd7762 [cfe] Refactor HierarchyBuilder
This removes the substitutions from ClassHierarchyBuilder and moves
the checking of inheritance conflict to the ClassHierarchyNodeBuilder.

Change-Id: I87a943102ab644c3b50acb07defb156e686225d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315102
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-24 14:55:14 +00:00
Chloe Stefantsova cc5ba81491 [cfe] Use term equality in place of identity in UP and DOWN
Closes https://github.com/dart-lang/sdk/issues/52997

Change-Id: I8b15ca1c4d2e3efbc8d7cdebeed1b16fe92d542b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315443
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-07-24 14:54:34 +00:00
Danny Tuppeny f191f235df [dds/dap] Fix some races in termination of test runs in DAP tests
It's not guaranteed that a "terminate" request will get a response so this changes the helper to accept a "terminated" event as acknowledgement of termination too.

It also fixes some issues running individual tests that didn't set a CWD (by setting a default for tests, since we can't "dart run test:test" without a cwd), and also updates a breakpoint test to not send breakpoints on invalid lines (something that had been fixed in the CLI test, but not the Test test).

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

Change-Id: I19dd60eb2b6d56035bb4d5b02d8e90713a8ce42d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315823
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-07-24 14:41:40 +00:00
Ilya Yanok 3911ef982d Try to fix _SubstitutedTypeParameters
It really looks like `_SubstitutedTypeParameters` factory
constructor assumes its `substitution` argument doesn't
include any of `elements` neither as a key, nor anywhere
it the result types. Since if it does contains a key from
`elements` that part of `substitution` will be lost, overriden by
`...substitution2.map` part of `Substitution.fromMap` call.
And if it has `elements` mentioned anywhere in values of the
`substitution` map, those won't be renamed.

But sometimes `_SubstitutedTypeParameters._SubstitutedTypeParameters`
is called with a `subtitution` that includes some of `elements`.
For example, that's what happens in both added tests.

I assume it never breaks, because the part of `substitution`
that acts on `elements` is trivial: just renaming a type
variable to a fresh name. And since `_SubstitutedTypeParameters`
just gets yet another fresh name for it, that works.

One small problem arises though if a type variable renamed by
`substitution` has a bound that references the type variable itself
(like `T extends Foo<T>`). In that case bound gets substituted with the
`substitution` first, so `substitution2` doesn't work on it anymore.
So we end up with an element `T0 extends Foo<T1>`, where `T0` and
`T1` and two different fresh names for `T`.

This commit changes the order of substitutions when handling bounds,
such that the part of `substitution` that substitutes `elements` is
effectively ignored. That agrees with the existing behavior of
rewriting this part of `substitution` in the result, so it shouldn't
make things worse.

Change-Id: I8f68c4342aad0c8f59f7c01a6cfac074946529ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312401
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
2023-07-24 12:23:27 +00:00
Daco Harkes 72dd200f8a [pkg][dartdev] Error on native assets but not enabled
And only print logs if `-v` is passed.

TEST=pkg/dartdev/test/native_assets/

Bug: https://github.com/dart-lang/sdk/issues/50565
Change-Id: Iccf879c80ea01cb39f9dd0d13c2f515a885d11d2
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314721
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Hossein Yousefi <yousefi@google.com>
2023-07-24 11:25:06 +00:00
Martin Kustermann 11d820890e Use utf8.encode() instead of longer const Utf8Encoder.convert()
The change in [0] has propagated now everywhere, so we can use
`utf8.encode()` instead of the longer `const Utf8Encoder.convert()`.

As the checked-in SDK has been rolled to include [0] we can now rely on
the better return type.

[0] https://github.com/dart-lang/sdk/issues/52801

TEST=ci

CoreLibraryReviewExempt: Minor cleanup.
Change-Id: I2c0144023e03b2c265582d83a7fb9469b02f1570
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313563
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-24 09:28:38 +00:00
Konstantin Shcheglov 4bb8312b4a Revert "Move API declarations of elements into src/, re-export."
This reverts commit 43db92d9ed.


Revert "Tweaks for comments of classes around augmentations."

This reverts commit 6d0fb5094f.

Change-Id: I9508169158d536302579346defebf696edfe4bec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315660
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-23 16:43:30 +00:00
Jia Hao Goh 11d0f060ef [dart2wasm] Fix location RangeError when using part
Here's a minimal repro that this CL fixes:

`ui.dart`

```dart
library dart.ui;

import 'dart:ffi';

part 'foo.dart';
```

`foo.dart`

```dart
part of dart.ui;

@Native<Void Function()>(symbol: 'foo_func', isLeaf: true)
external void foo_func();
```

When compiling with `compile_platform.dart` with `--target=dart2wasm`, the following error appears:


```
Unhandled exception:
Verification error: Target=wasm, VerificationStage.afterModularTransformations: Invalid location with target 'wasm' on FunctionNode() (FunctionNode): RangeError (offset): Invalid value: Not in inclusive range 0..56: 91
Context: 'foo_func_$import'.
Node: 'FunctionNode()'.
#0      VerificationErrorListener.reportError (package:kernel/verifier.dart:81:5)
#1      VerifyingVisitor.problem (package:kernel/verifier.dart:222:14)
#2      VerifyingVisitor._getLocation (package:kernel/verifier.dart:1361:7)
#3      VerifyingVisitor._hasLocation (package:kernel/verifier.dart:1370:26)
#4      VerifyingVisitor.getSameLibraryLastSeenTreeNode (package:kernel/verifier.dart:1342:28)
#5      VerifyingVisitor.localContext (package:kernel/verifier.dart:1382:24)
#6      VerifyingVisitor.defaultDartType (package:kernel/verifier.dart:1491:41)
#7      Visitor.visitVoidType (package:kernel/visitor.dart:1309:37)
#8      VoidType.accept (package:kernel/ast.dart:11190:42)
#9      FunctionNode.visitChildren (package:kernel/ast.dart:3919:16)
#10     VerifyingVisitor.visitChildren (package:kernel/verifier.dart:259:10)
#11     VerifyingVisitor.visitWithLocalScope (package:kernel/verifier.dart:266:5)
#12     VerifyingVisitor.visitFunctionNode (package:kernel/verifier.dart:721:5)
#13     FunctionNode.accept (package:kernel/ast.dart:3908:38)
#14     VerifyingVisitor.visitProcedure (package:kernel/verifier.dart:620:19)
#15     Procedure.accept (package:kernel/ast.dart:3311:40)
#16     visitList (package:kernel/ast.dart:14488:14)
#17     Library.visitChildren (package:kernel/ast.dart:591:5)
#18     VerifyingVisitor.visitChildren (package:kernel/verifier.dart:259:10)
#19     VerifyingVisitor.defaultTreeNode (package:kernel/verifier.dart:196:5)
#20     TreeVisitor.visitLibrary (package:kernel/visitor.dart:503:35)
#21     VerifyingVisitor.visitLibrary (package:kernel/verifier.dart:367:11)
#22     Library.accept (package:kernel/ast.dart:577:38)
#23     visitList (package:kernel/ast.dart:14488:14)
#24     Component.visitChildren (package:kernel/ast.dart:14320:5)
#25     VerifyingVisitor.visitChildren (package:kernel/verifier.dart:259:10)
#26     VerifyingVisitor.visitComponent (package:kernel/verifier.dart:342:7)
#27     Component.accept (package:kernel/ast.dart:14313:38)
#28     VerifyingVisitor.check (package:kernel/verifier.dart:171:15)
#29     verifyComponent (package:kernel/verifier.dart:69:20)
...
```

The issue seems to be that after doing this native transformation, the node's `fileUri` references the enclosing library (`ui.dart` above), but the `node.location` references the actual source file (`foo.dart` above) indirectly through `node.fileOffset`.

This ends up being an issue when compiling the platform dill in Google3,   but I didn't look into why `flutter build web --wasm` isn't broken.

Internal bug: b/292172146

Change-Id: I2b8d7d215b2c36354860257ce651d50168e9523d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315360
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jia Hao Goh <jiahaog@google.com>
2023-07-21 23:08:28 +00:00
Anna Gringauze a322a97fac [ddc] Add debugger runtime API
Define debugger runtime API so the debugger can display objects without knowing DDC implementation details.

- Add new DDC debugger runtime API in `debugger.dart`
- Add helpers for getting some type information in new and old type systems
- Add tests


Closes: https://github.com/dart-lang/sdk/issues/52773
Change-Id: I8efa4cacebb0d73ef58b5360979089cba2039379
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311154
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2023-07-21 20:10:15 +00:00
Konstantin Shcheglov 4854aabac9 Stop expecting 'inlineKeyword' during class parsing.
Inline classes will be replaced with extension types.

Change-Id: I9472dfbb92f7f50a4649e6f1953481a9ac237fe3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313284
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-21 19:12:48 +00:00
Ömer Sinan Ağacan 37581cb79e [dart2wasm] Fix names of dynamic call entry functions
Currently all closure dynamic call entries have the same name. This
makes it difficult to find locations of crashes. Example:

    wasm-function[677]:0x1de1d: RuntimeError: illegal cast
    RuntimeError: illegal cast
        at dynamic call entry (wasm://wasm/000909b2:wasm-function[677]:0x1de1d)
        at method forwarder for 'call' (wasm://wasm/000909b2:wasm-function[583]:0x1b474)
        ...

With this we now add the function name before "dynamic call entry":

  wasm-function[677]:0x1de1d: RuntimeError: illegal cast
  RuntimeError: illegal cast
      at C.m1 tear-off dynamic call entry (wasm://wasm/000921c6:wasm-function[677]:0x1de1d)
      at method forwarder for 'call' (wasm://wasm/000921c6:wasm-function[583]:0x1b474)
      ...

Which makes it easy to find the function in .wat output as there is only
one function with the name "C.m1 tear-off dyamic call entry".

Change-Id: Iea726b695fc29b361a347b64194d5c09601a0999
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315440
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 17:48:38 +00:00
Konstantin Shcheglov 6d0fb5094f Tweaks for comments of classes around augmentations.
Change-Id: If380225009237ca260cfb11b0f1861b50d34cae4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315223
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-21 17:42:32 +00:00
Ömer Sinan Ağacan 8b709ded96 [dart2wasm] Generate type names in names section
Change-Id: I35879dba0e5e4ecee279bdd8bf725798cd806595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315402
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 17:36:47 +00:00
Johnni Winther 65ce98f6de [cfe] Report error on cyclic extension types
Change-Id: I556a7fb63818879ac4adf94e070f68bf3b732036
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314440
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-21 17:34:28 +00:00
Konstantin Shcheglov 43db92d9ed Move API declarations of elements into src/, re-export.
In following CLs I plan to add `final` and `sealed` modifiers.

Change-Id: Ia6b9091034ed9f8f6f8576dbe6029d7e72a9d6b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315249
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-21 16:05:21 +00:00
Konstantin Shcheglov deb5fc8fa7 Don't report DUPLICATE_DEFINITION for augmentations of class / mixin / method.
Change-Id: I7c8e14216df650fbd6876a8087005a3bd3e82595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315248
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-21 15:59:08 +00:00
Aske Simon Christensen bac7e9b8c0 [dart2wasm] Emit encoding for final types.
This marks all types without subtypes as final and all types with
subtypes as non-final. This makes the emitted types maximally final
and is appropriate for a closed-world module.

V8 currently ignores the finality of types for the temporary WasmGC
encoding, which make our current encoding work even though it
implicitly marks some types as final that shouldn't be. For the final
WasmGC instruction encoding, V8 is likely to reject modules containing
final types with subtypes.

Change-Id: If3030c49e8fe60fec8099b731b6fcf618d6a7e64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310163
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 15:52:38 +00:00
Sam Rawlins 892fdd9ab0 Move all comment-parsing code into pkg/analyzer
I did not change the content of the functions, except the following:

* modernized some variable declarations with `var`.
* added periods to the end of comments.
* privatized most methods.

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

Change-Id: I4d63d3ee847316b58fa76c12558767c0825027a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315243
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-21 15:19:38 +00:00
Jake Macdonald 9803ffef27 Add support for macros adding mixins and interfaces to existing types in
the types phase.

Also seales the Code types hierarchy to block users from attempting to
create their own subclasses.

Bug: https://github.com/dart-lang/language/issues/3211
Change-Id: I51ebdfdad6e1fba3c19ef91f25e238730e98e740
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314821
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-07-21 15:18:33 +00:00
Paul Berry 82a196387d Allow .pattern only on const expressions.
Previously, when using the "mini-ast" pseudo-language to write unit
tests for the flow analysis and type analysis logic in the
`_fe_analyzer_shared` package, it was possible to call `.pattern` on
any arbitrary expression, creating a constant pattern containing the
expression. This didn't make sense--only constant expressions can be
used as the basis for constant patterns.

With this change, `.pattern` is only available on the various forms of
constant expressions supported by the "mini-ast" pseudo-language
(currently: integer literals, the `null` literal, and placeholder
expressions created using the `expr` function).

Change-Id: I0d87c66bdb8e636615b20bbb6207c38d78d0d2dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315245
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 14:52:26 +00:00
Paul Berry 64ecabdf16 Add function second to flow analysis tests.
In several flow analysis tests we need to model an expression with two
subexpressions, where the type of the overall expression is the same
as the type of the second subexpression.

Previously we did this using `ProtoStatement.thenExpr`, which created
a magic compound expression consisting of an expression (or statement)
followed by a second expression. This was too general, since it
allowed modelling code that would not be possible in Dart.

This CL replaces uses of `ProtoStatement.thenExpr` with a function
`second`, which models a Dart function defined this way:

    T second(dynamic x, T y) => y;

This has two advantages:

- The tests are now modelling code that could actually exist in the
  real world, rather than modelling pseudo-expressions that are not
  actually possible to write in Dart.

- It prepares for a follow-up CL in which I'll be unifying the
  representation of patterns and expressions in the flow analysis
  tests; eliminating `ProtoStatement.thenExpr` will prevent a conflict
  between it and `PossiblyGuardedPattern.thenExpr`.

With this change, two tests had to be deleted, because the conditions
they were testing could no longer be expressed:

- `for_conditionBegin() handles not-yet-seen variables`

- `whileStatement_conditionBegin() handles not-yet-seen variables`

This is ok, because these tests were designed to verify correct
behavior in the circumstance where the client forgets to declare a
variable. This circumstance no longer arises, because the
`_FlowAnalysisImpl` constructor detects undeclared variables and
generates synthetic declarations for them.

Change-Id: I19275ba0b7fa143ce7051bf14d0d4c6f57a4ab8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315244
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 14:43:08 +00:00
Johnni Winther 9cbb27ae8a [cfe] Create builders for extension type declarations
Change-Id: I12251865e0657a6241e9e3ce905df83bda24e260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313566
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-21 14:39:41 +00:00
Paul Berry bcaab7e985 Make more "mini-ast" constructs into expressions.
The following functions, which are used to create constructs in the
"mini-ast" pseudo-language to write unit tests for shared flow
analysis and type analysis logic, now have a return type of
`Expression` rather than `Statement`:

- checkAssigned
- checkUnassigned
- getSsaNodes
- implicitThis_whyNotPromoted an expression

This allows them to be used either where an expression is exprected or
where a statement is expected, which should give us the ability to
write some tests that are not possible (or very difficult) to write
today.

Change-Id: Ie50e82ad05dc88182b59c99c11ffaac41515ebb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315460
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 13:24:37 +00:00
Jonas Finnemann Jensen c77b7a6eda Add diagnostics for platforms key in pubspec.yaml.
**Context:**
The `platforms` field is used to indicate what platforms are supported
by a given package. It's only relevant when publishing to pub.dev, or
similar package repository. If no `platforms` fields is supplied the
platforms will be detected based on `import` statements, also accounting
for conditional imports. See [pubspec reference][1] for details.

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

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

Change-Id: I7b9ea5e371bb1cce6410d32fe6f38c49bc2ff69e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309661
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
Commit-Queue: Jonas Jensen <jonasfj@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-07-21 12:04:19 +00:00
Johnni Winther 5fae2e484b [parser] Add parser support for extension type syntax
Change-Id: I6bf6c118b4daa2bed438f8f406b9aef6aacf439e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313501
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 12:01:10 +00:00
Chloe Stefantsova d3b2b764a1 [cfe] Remove 'value-class' experimental flag
Change-Id: I9bcb9e30732503c9da4e723ded863949f5f0f1b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315200
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-07-21 11:16:24 +00:00
Johnni Winther 46086e908c [cfe] Disallow script tag in part file
In response to https://github.com/dart-lang/sdk/issues/52575

Change-Id: I452575517c378dda3000b8fcbf4f66274b1583a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315420
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-21 11:08:48 +00:00
Ömer Sinan Ağacan 463e251334 [dart2wasm] Optimize some list operations
- Use `array.copy` and `array.fill` when possible.

- Use the Wasm array directly (instead of `[]` and `[]=`) when possible
  to avoid redundant bounds checks.

- `_GrowableList.insert` is rewritten to avoid a redundant write when
  the element is not added to the end.

- Remove redundant bounds checks when calling `Lists.copy`.

Change-Id: I08d96b56201cbb4ff24ca969b7fde8bcc1315e4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315120
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 10:29:46 +00:00
Danny Tuppeny d53070ac75 [analysis_server] Add tests for Windows drive letter encoded colon issue
See https://github.com/dart-lang/sdk/issues/53000

Committing separately to the revert of pathContext.fromUri() so if in future that CL is reverted (to re-land the change), it doesn't remove these tests.

Change-Id: I922e5e770a0c8dfcfc6a1cd41f6734d88c2edf7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-21 01:53:12 +00:00
Danny Tuppeny be4189f047 [analysis_server] Revert use of pathContext.removeUri from LSP server
pathContext.removeUri does not handle escaped colons in drive letters (`Uri.toFilePath()` does), which VS Code currently sends.

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

Change-Id: Ic500404827a51afe3ffb14985df30fc98ba612f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-20 21:36:43 +00:00
Konstantin Shcheglov d90d50ae84 Use shared mixins _HasAugmentation / _HasAugmentationTarget.
WDYT?

Change-Id: I95f517f3645fce5fc434f8dcf451d6807d3635f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314864
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-20 21:34:21 +00:00
Joshua Litt 63786015f3 [dart2wasm|jscm] Move typed data to JS.
Change-Id: Ic4381818be9fdf3725a7eef8455451447a210b8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313281
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-07-20 20:31:38 +00:00
Sam Rawlins a458bab09a Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT
Fixes https://github.com/dart-lang/sdk/issues/49025

Change-Id: I401093e5b76bcf707060ce022c346e26c6807aa0
Tested: try-bots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303261
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-20 18:33:58 +00:00
pq 15acd7f16a make @useResult checking interpolation expression aware
Fixes: https://github.com/dart-lang/sdk/issues/51543

Change-Id: I10c02e278b303bc177985ff833eb79b6fc714a1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314865
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-07-20 16:01:08 +00:00
Paul Berry 7dc587d344 Simplify handling of switch heads in shared analysis tests.
When using the "mini-ast" pseudo-language to write unit tests for the
flow analysis and type analysis logic in the `_fe_analyzer_shared`
package, it is no longer necessary to use `.switchCase` to turn a
`Pattern` (or a `GuardedPattern`) into a `SwitchHead`; this now
happens automatically. The way this works under the hood is that the
`PossiblyGuardedPattern`, and `SwitchHead` classes implement the
`ProtoSwitchHead` interface; constructs that expect switch heads are
declared with input parameters of type `ProtoSwitchHead`, and they
automatically convert to switch heads when necessary.

Change-Id: Ic16264fc52ffff08bf0e0cc72db064a6da63eda5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315180
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-20 15:20:57 +00:00
Paul Berry ecf71eb63b Simplify handling of collection elements in shared analysis tests.
When using the "mini-ast" pseudo-language to write unit tests for the
flow analysis and type analysis logic in the `_fe_analyzer_shared`
package, it is no longer necessary to use `.asCollectionElement` to
turn an expression into a collection element; this now happens
automatically. The way this works under the hood is that both the
`CollectionElement` and `Expression` classes mix in the
`ProtoCollectionElement` mixin; constructs that expect collection
elements are declared with input parameters of type
`ProtoCollectionElement`, and they automatically convert expressions
to collection elements when necessary.

Also, instead of using `.inContextElementType` to establish the
appropriate context when testing a collection element, the tests not
simply create a `listLiteral` of the appropriate type, containing the
appropriate collection elements. This makes the unit tests much more
similar to the way actual Dart code is written in the wild, and makes
the test infrastructure more closely mirror the way types are analyzed
by the analyzer and CFE.

Change-Id: Ib628ff12caa84254df069308ae3a25061377db29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314141
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-20 13:14:24 +00:00
Johnni Winther 2172993731 [cfe] Add test for issue 52941
Change-Id: I5f40ab64923e6b1612e41fd96e3b92d52e2f79b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314720
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-20 12:08:31 +00:00
Ömer Sinan Ağacan 0f54180b51 [dart2wasm] New typed data implementation
New typed data implementation that optimizes the common cases.

This uses the best possible representation for the fast case with a
representation like:

    class _I32List implements Int32List {
      final WasmIntArray<WasmI32> _data;

      int operator [](int index) {
        // range check
        return _data.read(index);
      }

      void operator []=(int index, int value) {
        // range check
        _data.writeSigned(index, value);
      }

      ...
    }

This gives us the best possible runtime performance in the common cases
of:

- The list is used directly.
- The list is used via a view of the same Wasm element type (e.g. a
  `Uint32List` view of a `Int32List`) and with aligned byte offset.

All other classes (`ByteBuffer`, `ByteData`, and view classes)
implemented to be able to support this representation.

Summary of classes:

- One list class per Dart typed data list, with the matching Wasm array
  as the buffer (as shown in the example above): `_I8List`, `_U8List`,
  `_U8ClampedList`, `_I16List`, `_U16List`, ...

- One list class per Dart typed data list, with mismatching Wasm array
  as the buffer. These classes are used when a view is created from a
  list, and the original list has a Wasm array with different element
  type than the view needs. `_SlowI8List`, `_SlowU8List`, ...

  These classes use `ByteData` interface to update the buffer.

- One list class for each of the classes listed above, for immutable
  views. `_UnmodifiableI32List`, `_UnmodifiableSlowU64List`, ...

  These classes inherit from their modifiable list classes and override
  update methods using a mixin.

- One `ByteData` class for each Wasm array type: `_I8ByteData`,
  `_I16ByteData`,
  ...

- One immutable `ByteData` view for each `ByteData` class.

- One `ByteBuffer` class for each Wasm array type: `_I8ByteBuffer`,
  `_I16ByteBuffer`, ...

- A single `ByteBuffer` class for the immutable view of a byte buffer.

  We don't need one immutable `ByteBuffer` view class per Wasm array
  type as `ByteBuffer` API does not provide direct access to the buffer.

Other optimizations:

- `setRange` now uses `array.copy` when possible, which causes a huge
  performance win in some benchmarks.

- The new implementation is pure Dart and needs no support or special
  cases from the compiler other than the Wasm array type support and
  intrinsics like `array.copy`. As a result this removes a bunch of
  `entry-point` pragmas and significantly reduces code size in some
  cases.

Other changes:

- Patch and implementation files for typed data and SIMD types are split
  into separate files. `typed_data_patch.dart` and `simd_patch.dart` now
  only contains patched factories. Implementation classes are moved to
  `typed_data.dart` and `simd.dart` as libraries `dart:_typed_data` and
  `dart:_simd`.

Benchmark results:

This CL significantly improves common cases. New implementation is only
slower than the current implementation when a view uses a Wasm array
type with incompatible element type (for example, `Uint32List` created
from a `Uint64List`).

These cases can still be improved by overriding the relevant `ByteData`
methods. For example, in the example of `Uint32List` view of a
`Uint64List`, by overriding `_I64ByteData.getUint32` to do a single read
then requested bytes don't cross element boundaries in the Wasm array.
These optimizations are left as future work.

Some sample benchmarks:

vector_math matrix_bench before:

    Binary size: 133,104 bytes.
    MatrixMultiply(RunTime): 201 us.
    SIMDMatrixMultiply(RunTime): 3,608 us.
    VectorTransform(RunTime): 94 us.
    SIMDVectorTransform(RunTime): 833 us.
    setViewMatrix(RunTime): 506 us.
    aabb2Transform(RunTime): 987 us.
    aabb2Rotate(RunTime): 721 us.
    aabb3Transform(RunTime): 1,710 us.
    aabb3Rotate(RunTime): 1,156 us.
    Matrix3.determinant(RunTime): 171 us.
    Matrix3.transform(Vector3)(RunTime): 8,550 us.
    Matrix3.transform(Vector2)(RunTime): 3924 us.
    Matrix3.transposeMultiply(RunTime): 201 us.

vector_math matrix_bench after:

    Binary size: 135,198 bytes.
    MatrixMultiply(RunTime): 42 us.
    SIMDMatrixMultiply(RunTime): 2,068 us.
    VectorTransform(RunTime): 12 us.
    SIMDVectorTransform(RunTime): 272 us.
    setViewMatrix(RunTime): 82 us.
    aabb2Transform(RunTime): 167 us.
    aabb2Rotate(RunTime): 147 us.
    aabb3Transform(RunTime): 194 us.
    aabb3Rotate(RunTime): 199 us.
    Matrix3.determinant(RunTime): 70 us.
    Matrix3.transform(Vector3)(RunTime): 726 us.
    Matrix3.transform(Vector2)(RunTime): 504 us.
    Matrix3.transposeMultiply(RunTime): 53 us.

FluidMotion before:

    Binary size: 121,130 bytes.
    FluidMotion(RunTime): 270,625 us.

FluidMotion after:

    Binary size: 110,674 bytes.
    FluidMotion(RunTime): 71,357 us.

With bound checks omitted (not in this CL), FluidMotion becomes
competitive with `dart2js -O4`:

FluidMotion dart2js -O4:

    FluidMotion(RunTime): 47,813 us.

FluidMotion this CL + boud checks omitted:

    FluidMotion(RunTime): 51,289 us.

Fixes #52710.

Tested: With existing tests.
Change-Id: I33bf5585c3be5d3919a99af857659cf7d9393df0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312907
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-20 09:47:39 +00:00
William Hesse 9692a9dfef Revert "Balance tests equally across shards."
This reverts commit f827eb3a78.

Reason for revert: The tests being run, and the results being compared to, are changing dramatically, causing all sorts of test results going from [status] -> Skipped and from New Test -> [status].

Something is really going wrong.

Original change's description:
> Balance tests equally across shards.
>
> The sharded test runner invocations are now passed the previous results
> which contains the test timing, which are used to simulate how long each
> shard would take to run. The shards are now balanced as evenly as
> possible on a test level, taking multiple cores into account.
>
> Sharded tests are now run starting with the slowest test first, such
> that extremely long running tests finish as early as possible. This
> behavior ensures the cores are saturated and can be padded with fast
> tests near the end, rather than waiting for a few slow tests to complete
> while the rest of the system is idle.
>
> The algorithm works very well whenever it's able to accurately predict
> the time to run shards. In a number of cases, the model doesn't quite
> reflect reality and the data, which makes it fairly imperfect but still
> reasonably good. I think a second order feedback loop might kick in once
> it reorders the tests across shards and the test timing data reflects
> the new test timings.
>
> Multitests are no longer always sent to the same shard, since the data
> isn't available at the moment, and the change as-is speeds up the test
> running considerably.
>
> The front end unit test suites currently ignore the feature as there are
> no benefits yet to improving those quick shards.
>
> Upgrade the language version to 3.0.0 so patterns can be used and fix
> a mixin not being a mixin.
>
> Fixes: b/291585137
> Change-Id: I3cc1b1d96038d5b46e836b091e299097717c226c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314081
> Reviewed-by: William Hesse <whesse@google.com>
> Commit-Queue: Jonas Termansen <sortie@google.com>

Change-Id: I233e4bfa6d6ecf0cea4f97c1e47f1635f7b9040c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315060
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: William Hesse <whesse@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-07-19 23:56:06 +00:00
Mayank Patke b336f3900b [dart2js] Bailout tracing of record fields when record is bailed out
Fixes: #52968
Change-Id: Ie59d4c0f903089622bc260d471bc136fa91eacde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315020
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2023-07-19 23:34:46 +00:00
Konstantin Shcheglov 5494c1ce66 Resolve method invocations, both kinds of property access, to augmentations.
Change-Id: Idc776003154037bcdcba5ba24afd7326e4b7f527
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314861
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-19 22:20:28 +00:00
pq c4e3e95db2 fix deletion range in remove_non_null_assertion
Fixes: https://github.com/dart-lang/sdk/issues/52913


Change-Id: Ide13776ec15ff706c532b495e8203204afb1c667
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314862
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-19 22:15:12 +00:00
Konstantin Shcheglov 2cac4abcc6 Don't add augmentations of class / mixin to export scope.
Change-Id: I4c75ea3347bbbeee4bed17f0530dd75b72aace2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314940
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-19 19:53:34 +00:00
Konstantin Shcheglov 688fdb086d Support for property accessors in augmentations.
Change-Id: I06e68030f3f1c0b9cb86df2abd7ba9b90d93f5e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314585
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-19 19:49:51 +00:00
Joshua Litt 5016361ccd [dart2wasm] Refactor core.dart to make it easier to patch.
Now that we no longer need to put boxes in `core.dart`, it makes sense to move them out of `core.dart` so that we can patch these classes and their helper functions. This CL moves `BoxedInt` and `BoxedDouble` out of core patch, and moves some of their intrinsics / helpers to side libraries.

Tested: Dart2Wasm internal refactor of patch files.
Change-Id: I1dac95089a8bd9e2c8ee4f467a0d6f2792f9d665
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313900
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-07-19 17:05:36 +00:00
pq 04aa5727be update make_class_abstract correction to handle class modifiers
Fixes: https://github.com/dart-lang/sdk/issues/52948

Change-Id: I3ceae27555b6b1904c01753a432a89314a183c21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314583
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-07-19 16:36:19 +00:00
Konstantin Shcheglov 81b64fc273 Resolve 'this' in class / mixin augmentations. Resolve method invocations to augmentations.
Note, that resolving against implicit 'this' is not implemented yet.
The instance scope is not correct yet.

Change-Id: I71ea51f82c5fa0a19ea77593df19be29189782fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-19 15:42:46 +00:00
eliasyishak d662bf77aa Bumping revision + adding method to analytics mock
Change-Id: Iec426ca68089893aca4f59fe29bef7d28074627c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314560
Commit-Queue: Elias Yishak <eliasyishak@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-19 15:36:49 +00:00
Jake Macdonald 1b99100e2e Add API for resolving any identifier in the final macro phase.
- Rename declarationOf to typeDeclarationOf.
- Add declarationOf api for general declarations.
- Tighten the type of typeDeclarationOf in the final phase to avoid unnecessary
  casts in user code.
- Refactor message handling a bit to unify the error handling.

Bug: https://github.com/dart-lang/language/issues/3216
Change-Id: Ia61da19374abec77853d37e110a08f7dfe0d3b10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314280
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2023-07-19 13:56:08 +00:00
Johnni Winther 4893acd579 [_fe_analyzer_shared] Add test for issue 52908
Change-Id: I6e1559832107a5d422731664ab309da5575e37be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314400
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-19 13:54:10 +00:00
Jonas Termansen f827eb3a78 Balance tests equally across shards.
The sharded test runner invocations are now passed the previous results
which contains the test timing, which are used to simulate how long each
shard would take to run. The shards are now balanced as evenly as
possible on a test level, taking multiple cores into account.

Sharded tests are now run starting with the slowest test first, such
that extremely long running tests finish as early as possible. This
behavior ensures the cores are saturated and can be padded with fast
tests near the end, rather than waiting for a few slow tests to complete
while the rest of the system is idle.

The algorithm works very well whenever it's able to accurately predict
the time to run shards. In a number of cases, the model doesn't quite
reflect reality and the data, which makes it fairly imperfect but still
reasonably good. I think a second order feedback loop might kick in once
it reorders the tests across shards and the test timing data reflects
the new test timings.

Multitests are no longer always sent to the same shard, since the data
isn't available at the moment, and the change as-is speeds up the test
running considerably.

The front end unit test suites currently ignore the feature as there are
no benefits yet to improving those quick shards.

Upgrade the language version to 3.0.0 so patterns can be used and fix
a mixin not being a mixin.

Fixes: b/291585137
Change-Id: I3cc1b1d96038d5b46e836b091e299097717c226c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314081
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
2023-07-19 12:24:38 +00:00
Paul Berry a746b64aa7 Front end: remove unnecessary call to FlowAnalysis.propertyGet.
It is not necessary for `InferenceVisitorImpl.visitPropertyGet` to
call `FlowAnalysis.propertyGet` directly, because it already calls
`_computePropertyGet`, which calls `FlowAnalysis.propertyGet`.

Change-Id: I806337ff24bc237ef0e2a42af7357a70d6df7f4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313901
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-19 12:15:08 +00:00
Paul Berry 8dec57b546 Use shared logic for computing which fields are promotable.
This change replaces the CFE logic for deciding which fields are
promotable, so that it now makes use of the shared infrastructure in
`pkg/_fe_analyzer_shared`.

Since the shared logic doesn't depend on the CFE having already
computed `noSuchMethod` forwarders, it can be placed earlier in the
compilation pipeline, before top level type inference. As a result,
field promotion during top level type inference now works properly.

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

Change-Id: I451aa112a0af114a9c88dd64ebb8f199f6f6589e
Bug: https://github.com/dart-lang/sdk/issues/50522
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313860
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-07-19 12:14:47 +00:00
Anna Gringauze ab933fe9e5 [ddc tests] Fix expression compilation tests timeouts on JS exceptions
Fix timeout in expression compiler tests

Closes: https://github.com/dart-lang/sdk/issues/51740
Change-Id: I8fd2a321450b4a10235c97af640714a93c805f85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314620
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2023-07-18 23:35:07 +00:00
Marya Belanger eae32a7e92 Fix link and missing new line in generate.dart
Added a new line to _writeGlossary before the contents, because otherwise it was generating in the line directly below the contents of _writeHeader, and therefore not rendering properly. I also updated the link to [Customizing static analysis] as that changed recently and I've had to manually update it in the site-www doc version a couple times now.

Change-Id: I8c5d3d9adcc0004fc8d84d11935860617e7c2bfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314520
Commit-Queue: Marya Belanger <mbelanger@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-18 22:47:01 +00:00
Joshua Litt 9e37c2b480 [dart2wasm] Add JS compatibility mode.
The purpose of the wasm_js_compatibility target is to facilitate experiments with a JS compatibility mode for Dart2Wasm. Initially, we're just going to focus on typed data, but this will give us a place to experiment with moving List and String to JS as well.

In addition, someday down the road we hope to experiment with two additional compatibility changes:
1) Exclusively using double for all Dart numbers
2) Allowing undefined to flow as null.

The two major benefits of this approach are:
1) Much faster JS interop
2) To make it easier to bring up Dart2JS applications on Dart2Wasm

The only downside will be access overhead on the Wasm side, but the JS builtins proposal could potentially bring us close to parity with Wasm builtins someday.

Tested: Wasm specific trivial refactor.
Change-Id: I2c09426b6999507c1de6e584e9bc7072a088bda9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313240
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2023-07-18 19:34:38 +00:00
Paul Berry 130d6199c3 Field promotion: make the core promotability algorithm sharable; fix bugs
In the following code, it's not safe for the field `C._f` to undergo
type promotion, because a variable with static type `C` might have
type `D` at runtime, in which case `C._f` will get dispatched to
`noSuchMethod`, which is not guaranteed to return a stable result.

    class C {
      final int? _f;
    }
    class D implements C {
      noSuchMethod(_) => ...;
    }
    foo(C c) {
      if (c._f != null) {
        print(c._f + 1); // UNSAFE!
      }
    }

Therefore, in order to determine which fields are promotable, the
implementations need to analyze enough of the class hierarchy to
figure out which field accesses might get dispatched to
`noSuchMethod`.

Currently, the CFE does this by following its usual algorithm for
generating `noSuchMethod` forwarders before trying to determine which
fields are promotable. The analyzer, on the other hand, doesn't have
an algorithm for generating `noSuchMethod` forwarders (since it
doesn't implement execution semantics); so instead it has its own
logic to figure out when a `noSuchMethod` forwarder is needed for a
field, and disable promotion for that field.

But there's a chicken-and-egg problem in the CFE: the CFE needs to
determine which fields are promotable before doing top-level inference
(since the initializers of top-level fields might make use of field
promotion, affecting their inferred types--see #50522). But it doesn't
decide where `noSuchMethod` forwarders are needed until after
top-level inference (because the same phase that generates
`noSuchMethod` forwarders also generates forwarders that do runtime
covariant type-checking, and so it has to run after all top level
types have been inferred).

To fix the chicken-and-egg problem, I plan to rework the CFE so that
it uses the same algorithm as the analyzer to determine which fields
are promotable. This CL makes a first step towards that goal, by
reworking the analyzer's field promotability algorithm into a form
where it can be shared with the CFE, and moving it to
`package:_fe_analyzer_shared`.  Since this required a fairly
substantial rewrite, I went ahead and fixed #52938 in the process.

Fixes #52938.

Change-Id: I9e68f51b3ea9a967f55f15bdc445cc1c0efdabdd
Bug: https://github.com/dart-lang/sdk/issues/52938
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313293
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-18 18:54:26 +00:00