Commit graph

8246 commits

Author SHA1 Message Date
Johnni Winther 17f4344336 [cfe,analyzer] Handle extension types in exhaustiveness checking
This adds support for extension types in exhaustiveness checking by
performing extension type erasure on the type before computing the
corresponding static type/space.

Change-Id: Ie75c903aec52a7c34410695787a9bea6008d637d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340442
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-12-11 11:10:07 +00:00
Erik Ernst f9d64593ff Adjust UP to move the intersection type rules up
This CL implements the spec change in https://github.com/dart-lang/language/pull/3435. It changes the implementation of UP in the CFE and in the analyzer such that it matches the updated specification in language PR dart-lang/language#3435.

Change-Id: I2fb56c11e671e6917baffb89f9fb231072d22a0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333922
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2023-12-11 08:31:10 +00:00
Paul Berry 004f564f40 Allow "field promotion" to apply to abstract getters.
A quirk of analyzer and CFE implementations is that they resolve
property gets such as `foo.bar` to specific field or getter
declarations that may be not be directly defined on the target type;
for example if `foo` has type `B`, and `B` extends `A`, and `A`
contains a field called `bar`, then `foo.bar` is considered to refer
to `A.bar`, for example:

    class A {
      int? bar;
    }
    class B extends A {}
    f(B foo) {
      print(foo.bar); // Resolved to `A.bar`.
    }

This is in contrast with the language specification, which makes a
clean distinction between class _declarations_ and the _interfaces_
implied by those declarations. While a class declaration can contain
(among other things) both getters and fields, which might be concrete
or abstract, an interface doesn't distinguish between getters and
fields, and is inherently abstract.

The advantage of the analyzer/CFE approach is that it allows more
intuitive error messages and "go to definition" behavior, which
benefits users. But it has some ill-defined corner cases involving
complex class hierarchies, because not every property access can be
resolved to a unique declaration (sometimes a getter is multiply
inherited from multiple interfaces, for example). The language spec
approach has the advantage of being well-defined and consistent even
in situations involving complex class hierarchies.

When I initially implemented field promotion, I took advantage of this
quirk of the analyzer and CFE implementations, so that I could make
property gets that refer to field declarations promotable, while
keeping property gets that refer to abstract getter declarations
non-promotable. This caused unpredictable behaviors in the ill-defined
corner cases. It also meant that in certain rare cases, a property
access might not be promoted even when it would be sound to do so
(e.g. a property access might refer to a private abstract getter
declaration, but the only concrete _implementation_ of that abstract
getter was a final field).

This CL changes the rule for promotability so that any get of a
private property is considered promotable, provided that the
containing library doesn't contain any concrete getters, non-final
fields, or external fields with the same name. It no longer matters
whether the private property refers to a field or a getter. This rule
is simpler than the old rule, restores the spec's clean distinction
between class declarations and interfaces, and allows more promotions
without sacrificing soundness.

For additional details please see the breaking change announcement at
https://github.com/dart-lang/sdk/issues/54056, as well as the original
change proposal at https://github.com/dart-lang/language/issues/3328.

Fixes https://github.com/dart-lang/sdk/issues/54056.
Fixes https://github.com/dart-lang/language/issues/3328.

Change-Id: I38ffcb9ecce8bccb93b1b2586a1222a0fb1005a7
Bug: https://github.com/dart-lang/sdk/issues/54056
Bug: https://github.com/dart-lang/language/issues/3328
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337609
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-12-07 23:40:27 +00:00
Paul Berry 7dda27b543 inference-update-3: use unpromoted type as context for local variable assignments.
This change implements one of the features of experimental feature
`inference-update-3`: with the experimental feature enabled,
assignments to local variables use the declared (or inferred) type of
the local variable as the context for evaluating the RHS of the
assignment, regardless of whether the local variable is promoted. With
the experimental feature disabled, assignments to local variables
continue to use the promoted type of the local variable as the context
for evaluating the RHS of the assignment.

This eliminates one of the scenarios in which the context type of an
assignment is "aspirational" (i.e., not required to be met in order to
prevent a compile time error). Once all aspirational context types
have been removed from the language, we will be able to re-work
coercions to be based on context type, which fixes a number of
usability footguns in the language. See
https://github.com/dart-lang/language/issues/3471 for details.

Bug: https://github.com/dart-lang/language/issues/3471
Change-Id: Ic07ac1810b641a9208c168846cd5fd912088d62b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338802
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-12-07 23:30:06 +00:00
Chloe Stefantsova 408e4866f8 [cfe] Account for extension type self-dependency via raw types
Closes https://github.com/dart-lang/sdk/issues/54241

Change-Id: I7afcaab225f93763f0dd2852bb51227c05abe4bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340403
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-12-07 14:01:44 +00:00
Chloe Stefantsova d0aa049ae1 [cfe] Report cyclic dependency on declaration, not on type variable
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/339941/comment/356b962f_a73d18c8/

Change-Id: I193cee03bdfa766621d57dd4a47cc9f0da6c9c92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340440
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-12-07 13:21:29 +00:00
Jens Johansen c959173b4c [CFE/VM] Expression compilation when inside an extension type method
VM: De-mangle names as done with extension methods.
CFE: Handle #this as with extension methods.

TEST=ci
Change-Id: I512798632a016025bf30edf8a0586d9085b4e3cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339960
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-12-07 11:15:25 +00:00
Johnni Winther c6347389d2 [cfe] Move irrefutable tails into the case body
This moves pattern variable assignments of fully matched expressions into the case body. This will help backends (dart2js in particular) to reason about the code flow.

Closes #54115

Change-Id: I598a384a829f16e91ab2d6a309499cf20b9cc121
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339122
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-12-07 11:13:30 +00:00
David Morgan 296a7f642e [macros] Remove Introspectable* types.
Per https://github.com/dart-lang/language/issues/3442 inrospection will
be allowed to succeed if possible, failing if there are cycles.

Change-Id: I341cc4ae87d1399df82cebb1d5c9df7e5070e777
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339620
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
2023-12-07 09:44:59 +00:00
Srujan Gaddam b1a7ca77e0 [dart:js_interop] Move JS types to extension types
- Removes @staticInterop JS types declarations in favor of
typedefs (the function types' reified types and the typed data's
reified types have changed to make the type hierarchy work in the
JS backends).
- Adds extension types to dart:js_interop
- Adds a fromInteropObject helper to JSObject to avoid casting to
an extension type
- Deletes now stale tests
- Refactors some dart2wasm @staticInterop declarations since they
can no longer implement JS types
- Updates extension types tests to use the prefix extension_type
instead of inline_class
- Updates comments

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: Ibe04afac9585ddb99fcf6dbaa7f12050d8b876dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332860
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-12-06 21:59:58 +00:00
Chloe Stefantsova 2d0e056672 [cfe] Check for cyclic typedefs at declare site instead of use site
Change-Id: I3738cd483b6436c630669edd6975b0fbb078d058
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339941
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-12-06 16:11:42 +00:00
Paul Berry 08405de9c6 Fix parser crash when skipping unmatched begin tokens.
Sometimes when the parser is performing error recovery it skips tokens
until it finds the next `,` or `;`, to try to get back on track. This
is handled by the `Parser.findNextCommaOrSemicolon` method.

When this method encounters a `BeginToken` (i.e., `(`, `[`, `{`, or
`<`), it needs to skip to the matching end token (using the `endToken`
getter), so that it doesn't try to resume parsing inside some nested
structure.

However, sometimes there is no matching end token (either because the
user has failed to properly matched `()`, `[]`, or `{}`, or because
the `BeginToken` is `<`, which doesn't always have a matching `>`). To
avoid a crash when this happens, `Parser.findNextCommaOrSemicolon`
needs to treat an unmatched `BeginToken` like an ordinary token, and
just advance to the next token.

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

Bug: https://github.com/dart-lang/sdk/issues/54236
Change-Id: Id208c7a46c9c00b69f7f460a638d59486ebaffea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339980
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-12-06 15:01:19 +00:00
Johnni Winther 732a068f9d [cfe] Handle equals on Never in pattern matching
This normalizes the handling of Object member access on Never by
adding a NeverAccessTarget which holds the needed member and function
type information.

Closes #54230

Change-Id: I4bfb9d746a4abd7094e87f907db7c9298fcd0361
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340183
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-12-06 13:58:48 +00:00
Jens Johansen f5743b9f44 [CFE] Expression compilation: Use static type for extension types
This - combiend with sending the scriptUri and offset - allows us to
expression evaluate stuff on extension types.

Change-Id: I0db6c1f52ad3db4ce1a1a2a721e8f3e70033f9ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339900
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-12-06 12:03:09 +00:00
Johnni Winther 85cb56dd20 [cfe] Don't use late final for pattern caching
This changes the pattern matching lowering to avoid using late final variables (or lowerings thereof) and instead inline the initializer where used. This avoids generating closures that are hard for backends to reason about and optimize.

Closes #52805
Closes #53804

Change-Id: Ia887446dd4d4475d05cf852c812bfe4b851de261
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338860
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-12-06 12:01:38 +00:00
Paul Berry d79b9d8cd2 Add experiment flag inference-update-3.
I plan to use this to guard my work on
https://github.com/dart-lang/language/issues/3471.

Bug: https://github.com/dart-lang/language/issues/3471
Change-Id: I49afae7260c14b8c6b646ccc0ee39efae3891c34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338649
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-12-05 17:50:30 +00:00
Johnni Winther f8ac221972 [cfe] Report errors on deferred types in extends/with/implements clauses
Change-Id: I5a66f072f5c29cbe720bf59cf8d3c0fd28b52bd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339121
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-12-05 13:21:12 +00:00
Simon Binder a44a524bb0 [vm/ffi]: Add Native.addressOf
This adds the `Native.addressOf` function, which takes a constant tear-
off of a method annotated with `@Native` as a parameter and returns a
pointer to the underlying C function.

The CFE will resolve these calls in two steps: First, the existing
transformer for `@Native` methods adds a pragma describing the fully-
resolved native annotation (with the asset id inferred from the library
if not given explicitly). Then, the FFI use sites transformer rewrites
calls to `Native.addressOf` by searching for this pragma on the passed
function and passing the `Native` constants to `Native._addressOf`. The
latter method is implemented in the VM, which can re-use existing parts
already used for `@Native` calls.
An alternative implementation strategy would have been to forward
`addressOf` calls to `Native.ffi_resolver_function` directly without
any special consideration in the VM. However, the chosen approach makes
it easier to support static linking in the future, as this requires
unresolved symbols in the generated assembly.

Closes https://github.com/dart-lang/sdk/issues/50552

TEST=pkg/vm/testcases/transformations/ffi/ffinative.dart
TEST=tests/ffi/native_assets/asset_*_test.dart
TEST=tests/ffi/vmspecific_static_checks_ffinative_test.dart
TEST=pkg/analyzer/test/src/diagnostics/ffi_native_test.dart

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-kernel-precomp-linux-release-x64-try
CoreLibraryReviewExempt: VM & dart2wasm only feature
Change-Id: Ic8e3a390146dffd44c95578f975a4472db79a0ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333920
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-05 13:10:36 +00:00
Jens Johansen 1f9d59c807 [CFE] More dart scope calculator stuff
General approach: Find all scopes for an offset,
then pick "the right one".

This still leaves a few offsets where we can't pick 1 scope in the
(non-outline) dills in the out directory though.

More thorough testing will follow.

TEST=ci

Change-Id: I66448498e07aa03f720733bcaf167bbfa30bca2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338840
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-12-04 11:25:19 +00:00
Parker Lougheed b8b67c066c [cfe] Correct PrivateNamedParameter problem message
Named parameters can't start with underscores whether they are optional or required.

Change-Id: Iaaeab80f74a691b4981148f06412a60ca115f73e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337883
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-12-01 17:32:48 +00:00
Alexander Markov 927091e8ac [dart2wasm] Fix invalid closure return type in async* lowering
dart2wasm lowering of async* methods includes call to Stream.where
which takes a closure. The return type of that closure was incorrectly
set to Object?, while it should be bool.

This incorrect static type becomes a problem with more precise
handling of closures in TFA.

Issue: https://github.com/dart-lang/sdk/issues/39692
Change-Id: I35a8a6b198413d564e091a935a8beaff15d6d541
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339200
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-12-01 14:06:18 +00:00
Johnni Winther ad625dfb5d [cfe] Use lazy-and instead of conditional expression for null-check pattern
In response to https://github.com/dart-lang/sdk/issues/54115

Closes #54114

Change-Id: I6d1d29c19173e703a467f43ec09a7de383b4a80b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338881
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-30 15:54:41 +00:00
Chloe Stefantsova 8caf3980fe [cfe] Avoid false positives in typedef self-dependency reporting
Closes https://github.com/dart-lang/sdk/issues/54186

Change-Id: I15a3cdfffc5d2ad032a8d4280fc2f011ccc6696b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339000
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-30 10:23:09 +00:00
David Morgan 54760c0382 [CFE] Remove enableMacros and forceEnableMacros global bools.
R=johnniwinther@google.com

Change-Id: Ic3f70209809176feff91e501c1d600df9f95d54f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338680
Auto-Submit: Morgan :) <davidmorgan@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-30 10:02:30 +00:00
David Morgan 26107a319a [CFE] Refactor macros setup.
Add `dispose` method to `ProcessedOptions` that does macro executor cleanup; add `dispose` method to MultiMacroExecutor for it to call.

R=asiva@google.com, jakemac@google.com

Change-Id: I90d9af133e84655ec14870400988fdee9adb219e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338440
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2023-11-30 08:08:11 +00:00
Jens Johansen bf9767ec5a [CFE] Fix nested ifs that doesn't make sense
E.g.

```
  final bool foo = (1+1==2) ? true : false;
  if (foo) {
    if (foo) {
      print("always true");
    }
    if (!foo) {
      print("always false");
    }
  }
```

Inside the first if we know `foo` to be true, so there's no reason to do
more if's on it.

Change-Id: I87d0827c47ce0e7277d951c0ec28f19dff09767a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338780
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-29 12:33:18 +00:00
Chloe Stefantsova ff363b5f15 [cfe] Avoid false positives on extension type depending on itself
Closes https://github.com/dart-lang/sdk/issues/54169
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: Ia4a8a2237785b0876461473f98af89b82ccc10eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338601
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-29 10:05:57 +00:00
Ian Hickson 86231e2d70 Remove the widget cache experiment.
Bug: https://github.com/flutter/flutter/issues/132157
Change-Id: Ie87ba74b8ed99477cc5032824286adb07f1157d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319871
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-29 08:47:59 +00:00
Jens Johansen 963068bd4e [CFE] Add offset tests for spreads
Change-Id: Ie0e39ce66820539fe4ae72fdde20b3ccbe46f1b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338561
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-29 08:38:03 +00:00
Johnni Winther 7c9ee204db [cfe] Report errors on abstract members and field in extension type
Includes a cleanup of the errors reported for duplicate instance field.
Previously, in addition to reporting the duplicate, we would report that
the field cannot be used because it is a duplicate and that the
duplicate field hasn't been initialized.

Closes #53467
Closes #53320

Change-Id: Ifd94223500809f3be36a1345d9d0c409778eed8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336885
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-11-28 23:29:06 +00:00
Jens Johansen 61b84f24a0 [CFE] Add tooling to signal linux perf tool to take a snapshot when recording intel_pt events
Change-Id: Id8b0959ab128f0c7a625d2a386292c4478957418
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333925
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-28 13:15:53 +00:00
Jens Johansen 6c9f95bd15 [CFE/DDC] Scope test adds context for type parameters; more testing
Change-Id: I218cc473ae2e48944b268094e08cf0da19a09bbd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337740
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-28 07:52:32 +00:00
Martin Kustermann ebb856af29 Also add global owners to CFE/VM packages
This is a follow-up CL to [0] that tightened ownership.

[0] https://dart-review.googlesource.com/c/sdk/+/337980

TEST=ci

Change-Id: Icccdf95cec886cb03b84951949210daa71d48f2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338121
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-11-27 14:35:52 +00:00
Jens Johansen 91a4759721 [CFE] Add more offset testcases wrt switch cases
Change-Id: I54208edcc4679ac0c36a248feae25f1b4e35a7d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338320
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-27 13:49:47 +00:00
Chloe Stefantsova 9c3f921c3f [cfe] Avoid prematurely calls of unsupported members
Closes https://github.com/dart-lang/sdk/issues/53560

Change-Id: If07d6a0eaa8b4e2a9754eec2e5acdfce2b65efca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336940
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-27 11:22:43 +00:00
Chloe Stefantsova c048054a0b [cfe] Type-check new possibilities for rederectee types of Enums
With the appearance of extension types one can write programs with
non-trivial subtypes of enum types, making the type checks of targets
of redirection necessary, even if they are generative constructors.

Closes https://github.com/dart-lang/sdk/issues/54010
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: Ic415678c6e0579c1acf6f2542ccd90eb24b86362
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336886
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-27 11:11:58 +00:00
Chloe Stefantsova b0a91e2eb4 [cfe] Only eliminate type variable itself in its bound in UP
Previously, UP was eliminating all free variables in the bound instead
of just the variable with that bound.

Closes https://github.com/dart-lang/sdk/issues/54062

Change-Id: Ic0ce9e6b53ecee7d9d1dcb4e76b9214310f63631
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336884
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-27 11:06:52 +00:00
Alexander Thomas a9cb6fbb0d [cleanup] Remove references to _2 tests from pkg/front_end
Bug: b/310114753
Change-Id: If8ffa9e6132d058e63608213d606056197c15e61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336962
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-27 09:10:34 +00:00
Martin Kustermann 31130b14e7 CLs that change VM/CFE packages should get approval from the corresponding team
TEST=none
Change-Id: Iee3d8921f0ee28dc384490d1e235108a50ade415
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337980
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-11-23 11:09:50 +00:00
Jake Macdonald e6ebb9340f remove unmeaningful constructor parameters from ConstructorDeclarationImpl
Change-Id: I1bb5712349198d3a1658c405a164aa38d447c752
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337660
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
2023-11-22 17:37:22 +00:00
Jake Macdonald a1b8fa4613 move hasAbstract from FunctionDeclaration to FieldDeclaration
Bug: https://github.com/dart-lang/language/issues/3454
Change-Id: Ic157dcd1e2c82c8cc08cd225065fd2810a8b02f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335240
Reviewed-by: Morgan :) <davidmorgan@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-11-21 23:18:10 +00:00
Paul Berry a19ae4ee68 Enable the extension types language feature.
This language feature allows the user to declare a static type using
`extension type` syntax, for example:

    extension type IdNumber(int i) {
      operator <(IdNumber other) => i < other.i;
      bool isValid(Some parameters) => ...;
    }

This behaves similarly to a "wrapper" class:

    class IdNumber {
      final int i;
      IdNumber(this.i);
      operator <(IdNumber other) => i < other.i;
      bool isValid(Some parameters) => ...;
    }

However, at runtime, no wrapper objects are created; instead, an
instance of the extension type is represented directly by its
"representation type" (`int` in the above example), and methods like
`isValid` are resolved statically. This gives developers an
abstraction mechanism with the advantage of zero runtime performance
cost, since no extra heap space is required, and no extra instructions
are needed to convert between an extension type and its underlying
representation.

The disadvantage of using extension types as an abstraction mechanism
is that since no wrapper objects are created at runtime, the
abstraction can be bypassed using `dynamic`, runtime casts, or by
"laundering" the object through contravariant generic methods like
`List.add` (which are runtime checked in Dart). For example:

    main() {
      var id = IdNumber(1);
      var list1 = <int>[];
      List<Object> list2 = list1;
      list2.add(id); // OK at compile time because `IdNumber` is a
                     // subtype of `Object`. OK at runtime because
		     // at runtime, `IdNumber` and `int` are
		     // indistinguishable.
      int i = list1[0];
      print(i);
    }

Extension types are expected to be particularly useful for
low-overhead decoding of external data formats (such as JSON), and for
inter-operation with other languages (such as Javascript).

For additional information see the feature specification:
https://github.com/dart-lang/language/blob/main/accepted/future-releases/extension-types/feature-specification.md

Change-Id: I900a3a25dcfc38bfa9c9f9b5b9fa20f362883653
Tested: Standard trybots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335062
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 19:14:49 +00:00
Tess Strickland 4bedb142d3 Reland "[pkg/vm] Handle switch statements in unreachable code eliminator."
This is a reland of commit 262311772b

When running with sound null safety, reducing a logical expression to
the right hand side if the left hand side is constant and does not short
circuit is valid, as the right hand side is guaranteed not to evaluate
to null.

In other modes, however, the right hand side may evaluate to null.
Thus, in thos modes, we return the original node if the RHS is not a
constant boolean value, so that the operator can perform whatever null
checking is required.

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

Original change's description:
> Reland "[pkg/vm] Handle switch statements in unreachable code eliminator."
>
> This is a reland of commit 92bf76d9e8
>
> In the original CL, the changes to the UCE assumed all
> SwitchStatements were exhaustive. Now if a SwitchStatement isn't
> explicitly or implicitly (via a default case) exhaustive and no case
> matches the tested constant, the SwitchStatement is properly removed.
>
> In addition, if a guaranteed to match case is found, more than one
> cases remain (thus the SwitchStatement is not removed or replaced with
> the single case's body), and the default case is removed, then the
> resulting SwitchStatement is marked as explicitly exhaustive, as this
> serves as a signal to backends that they do not need to handle the
> possibility of no case matching in the absence of a default case.
>
> Original change's description:
> > [pkg/vm] Handle switch statements in unreachable code eliminator.
> >
> > Namely, if the tested expression for a switch statement is constant,
> > then we can remove any constant cases where the constants differ,
> > and if all but a single case is removed, we can replace the switch
> > with the case body.
> >
> > If constant functions are not enabled, then getters annotated with
> > @pragma("vm:platform-const") are still evaluated with the constant
> > function evaluation machinery, but only those and no others (including
> > any functions called within an annotated getter). This way, functions
> > can be annotated with @pragma("vm:platform-const") without having to
> > rewrite them to be a single returned expression.
> >
> > TEST=pkg/vm/test/transformations/unreachable_code_elimination
> >      pkg/vm/test/transformations/vm_constant_evaluator
> >
> > Issue: https://github.com/dart-lang/sdk/issues/50473
> > Issue: https://github.com/dart-lang/sdk/issues/31969
> > Change-Id: Ie290d2f1f469326238d66c3d9631f8e696685ff0
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332760
> > Commit-Queue: Tess Strickland <sstrickl@google.com>
> > Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
> > Reviewed-by: Alexander Markov <alexmarkov@google.com>
>
> TEST=pkg/vm/test/transformations/unreachable_code_elimination
>      pkg/vm/test/transformations/vm_constant_evaluator
>
> Issue: https://github.com/dart-lang/sdk/issues/50473
> Issue: https://github.com/dart-lang/sdk/issues/31969
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try
> Change-Id: I557ca933808012e670e306f2d880221a0d7dd670
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334224
> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

TEST=pkg/vm/test/transformations/unreachable_code_elimination
     pkg/vm/test/transformations/vm_constant_evaluator

Change-Id: Ia51b7c5f3b51f57a6a306551fe74b47e0cba3c23
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335828
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-11-21 18:07:30 +00:00
Ryan Macnak c1143082fe Include ARM64 when uploading d8.
Change-Id: I613ca948734a849c43f6f6d02cfd678d18fe7e03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336200
Reviewed-by: Alexander Thomas <athom@google.com>
2023-11-21 17:15:20 +00:00
Moritz a3568286ff Adding the resource-identifier functionality from the compiler to the
vm.

This identifies all calls to static methods annotated with
`@ResourceIdentifier`, collects the constant arguments passed to the
method, and writes the results into a file.

The purpose of this feature is to be able to pass the recorded
information to packages in a post-compilation step, allowing them to
remove or modify assets based on the actual usage in the code prior to
bundling in the final application.

Tested: pkg/vm/test/transformations/resource_identifier_test.dart
Change-Id: I58cb313b66ee23c1d154dcc242547723a1ced359
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329961
Commit-Queue: Moritz Sümmermann <mosum@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-11-21 15:05:35 +00:00
Jens Johansen 40777c001a [CFE] Textual outline suite pretends the inline_class flag was flipped
Currently, if a not-enabled-by-default experimental flag is on we allow
formatting to fail.
This means that when the flag is flipped there's a risk of failures as
formatter crashes are now not allowed anymore.

The failures for flipping the extension types / inline-class feature
has caused crashes and was fixed before (twice!) in
https://dart-review.googlesource.com/c/sdk/+/336001
https://dart-review.googlesource.com/c/sdk/+/335448

But naturally a new test was added after
(https://dart-review.googlesource.com/c/sdk/+/336022) and we had a new
failure on the flag-flip CL.

This CL instead pretends like the inline-class flag is already flipped,
in that the formatter is not allowed to crash because of it.
That should make any new tests added before the flag is flipped that
would otherwise cause a failure upon flag flip, fail, forcing the
update of the status file.

The status file is furtermore updated.

Change-Id: Ifbc3d271a614e5dd747b35b252034087ad155a92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337321
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-21 10:23:48 +00:00
Daco Harkes df4ef72c01 [vm/ffi] Remove deprecated FfiNative
TEST=pkg/analyzer/test/
TEST=CI build with class removed from `dart:ffi`

Closes: https://github.com/dart-lang/sdk/issues/53923
CoreLibraryReviewExempt: VM & dart2wasm only.
Change-Id: I45a39b623754f9f1b65cac55ea9adae390199f5d
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm64c-try,analyzer-analysis-server-linux-try,analyzer-mac-release-try,dart-sdk-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336960
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-11-20 13:16:28 +00:00
Johnni Winther ced5b4e25d [cfe] Ensure nullable result type for ??= for effect
Closes #54069

Change-Id: I4caaad1b86f9ef68f1d36d7b2f9afc92364ce83c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336662
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-17 14:06:50 +00:00
Lasse R.H. Nielsen 5543293a16 Reland "Expire 3.0.0 experiment flags."
This is a reland of commit 6f29e7fce4

Original change's description:
> Expire 3.0.0 experiment flags.
>
> TEST=Existing tests covers.
> Change-Id: I161eefdc28c74f63ba1ee926800a01eea03d9930
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331960
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Alexander Thomas <athom@google.com>

TEST=Existing tests covers.
Change-Id: I384e77744c74774a250be413358a7fa176117167
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332684
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-11-17 13:10:01 +00:00
Johnni Winther 1e981c48a2 [cfe] Add test for issue 54070
Closes #54070

Change-Id: Ib3f081e0bb5c8d7fea16f30752a7e7a7bd6b339d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336640
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-16 14:52:29 +00:00
Johnni Winther 346662457d [cfe] Handle extension type constructor access through typedefs
Closes #53531
Closes #53563

Change-Id: Ibaf99f4255547d17545223ded58eba9e31d30175
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336421
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-16 11:47:57 +00:00
Johnni Winther 56a86e599e [cfe,ddc] Add tests for scopes in extensions, extension types and mixins
This adds support using experimental features in id testing in DDC and
uses it to add tests for scopes in extensions, extension types and
mixins.

The tests show that the DartScopeBuilder and DartScopeBuilder2 differ
on the scope on instance members in extensions and extension types for
the synthetic #this variable.

Change-Id: Iec0f3b938da567578b1245ada885370fb2a8b33f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335824
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-16 09:37:31 +00:00
Johnni Winther 3c456ccbd2 [cfe] Report error on constructor/static member conflict
Change-Id: I30c939e2d1dfe6e814b08e6ceac0bbb27af56f93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336400
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-11-15 16:30:30 +00:00
Chloe Stefantsova c6b0e218c7 [cfe] Make extension type non-nullable only if it implements Object
Part of https://github.com/dart-lang/sdk/issues/49731

TEST=existing

Change-Id: I397bbd5ca7868a9fb344286c910536c6ac341222
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333500
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-15 14:02:35 +00:00
Johnni Winther 000e67bb20 [cfe] Add test for Object member access
Change-Id: I3b9138a48878110f1af42afe8eee7a5338766378
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335823
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-11-15 12:47:23 +00:00
Johnni Winther 4eed065859 [cfe] Add CFE test for DartScope
This adds a CFE test for DartScope that shares the data with the
corresponding DDC test. The CFE test uses the DartScopeBuilder2
which is currently in development to replace the DartScopeBuilder.

Change-Id: I0d6c76957e7a5d28babab14110d430935e686b22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335821
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-15 10:17:23 +00:00
Johnni Winther 3e89b9b04e [cfe] Include const extension type constructors in outline
Closes #54008

Change-Id: If5135111760fdab7009d97aeda7cd65c93001d74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336022
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-11-15 10:10:58 +00:00
Sam Rawlins 73ab31b98a analyzer: Move the Source class to be public API.
Deprecate accessing LineInfo, Source, or SourceRange via the
old library (pkg/analyzer/lib/src/generated/source.dart).
Migrate all SDK code to the new library.

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

Change-Id: Ic7c98a5820415c92a457f9fa2756351b05520cd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-14 17:10:37 +00:00
Johnni Winther 77ec617fd8 [cfe] Add test for issue 53610
Closes #53610

Change-Id: Id8efa1cc31617fdd0f323cc1397db4c7519b370a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335522
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-11-14 13:50:51 +00:00
Jens Johansen a0bb10b675 [CFE] Let textual outline pass flags to the formatter; mark failures in status file
Before (or, currently) we force the `ExperimentalFlag.inlineClass`
experimental flag to be on and it's experimental and we thus basically
always allow the formatter to fail.
With the flag being flipped this allowing it to fail goes away.
This CL fixes some of it by passing flags to the formatter as well, and
"fixes" the rest by putting in status entries.

Change-Id: I059efa0473dc0746bd72b45071c69915d4472b07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336001
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-14 11:46:28 +00:00
Konstantin Shcheglov 7353eb80ce Macro. Run definitions phase.
Change-Id: I6786a70a13c708bbacb2b09258e358b1e8e18543
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335602
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-11-13 19:54:16 +00:00
Daco Harkes 92e61ea4b7 Revert "Reland "[pkg/vm] Handle switch statements in unreachable code eliminator.""
This reverts commit 262311772b.

Reason for revert: Breaks legacy mode.
Bug: https://github.com/dart-lang/sdk/issues/54029

Original change's description:
> Reland "[pkg/vm] Handle switch statements in unreachable code eliminator."
>
> This is a reland of commit 92bf76d9e8
>
> In the original CL, the changes to the UCE assumed all
> SwitchStatements were exhaustive. Now if a SwitchStatement isn't
> explicitly or implicitly (via a default case) exhaustive and no case
> matches the tested constant, the SwitchStatement is properly removed.
>
> In addition, if a guaranteed to match case is found, more than one
> cases remain (thus the SwitchStatement is not removed or replaced with
> the single case's body), and the default case is removed, then the
> resulting SwitchStatement is marked as explicitly exhaustive, as this
> serves as a signal to backends that they do not need to handle the
> possibility of no case matching in the absence of a default case.
>
> Original change's description:
> > [pkg/vm] Handle switch statements in unreachable code eliminator.
> >
> > Namely, if the tested expression for a switch statement is constant,
> > then we can remove any constant cases where the constants differ,
> > and if all but a single case is removed, we can replace the switch
> > with the case body.
> >
> > If constant functions are not enabled, then getters annotated with
> > @pragma("vm:platform-const") are still evaluated with the constant
> > function evaluation machinery, but only those and no others (including
> > any functions called within an annotated getter). This way, functions
> > can be annotated with @pragma("vm:platform-const") without having to
> > rewrite them to be a single returned expression.
> >
> > TEST=pkg/vm/test/transformations/unreachable_code_elimination
> >      pkg/vm/test/transformations/vm_constant_evaluator
> >
> > Issue: https://github.com/dart-lang/sdk/issues/50473
> > Issue: https://github.com/dart-lang/sdk/issues/31969
> > Change-Id: Ie290d2f1f469326238d66c3d9631f8e696685ff0
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332760
> > Commit-Queue: Tess Strickland <sstrickl@google.com>
> > Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
> > Reviewed-by: Alexander Markov <alexmarkov@google.com>
>
> TEST=pkg/vm/test/transformations/unreachable_code_elimination
>      pkg/vm/test/transformations/vm_constant_evaluator
>
> Issue: https://github.com/dart-lang/sdk/issues/50473
> Issue: https://github.com/dart-lang/sdk/issues/31969
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try
> Change-Id: I557ca933808012e670e306f2d880221a0d7dd670
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334224
> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

Issue: https://github.com/dart-lang/sdk/issues/50473
Issue: https://github.com/dart-lang/sdk/issues/31969
Change-Id: I56373c7a6feac76e23c1800ae83eb013c5856cba
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335820
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-11-13 16:39:09 +00:00
Jens Johansen e5ace00e2f [CFE] Don't try to format textual outline result from source with errors
Currently we don't get any failures from trying to format erroneous code
because we ignore formatting errors if there is an experimental feature
enabled, and the "inline class" experimental feature is always
forcefully enabled in testing.

With that experiment getting enabled
(https://dart-review.googlesource.com/c/sdk/+/335062) tests will start
failing because nothing stops us from formatting the erroneous code (and
nothing asks us to allow failures when we try).

This CL instead gives the test access to the needed information (i.e. if
there were parse errors or not), and won't try for format the code if
there is.

Change-Id: I2664cc544a9def9fad3058f6c80c130b8b6b6b4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335448
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-13 14:27:14 +00:00
Johnni Winther 6b5b3cc98a [cfe] Add test for issue 53485
Closes #53485

Change-Id: I3db3ebd30fc6b335406fa0c0e6303650c746e978
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335467
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-11-13 09:15:13 +00:00
Johnni Winther edec6c115c [cfe] Handle inference of erroneous setters
Closes #54006

Change-Id: I05c9352525d91196fcefd59ab244b3979b0cfcc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335465
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-13 09:13:16 +00:00
Johnni Winther 0dd30703e2 [cfe] Add test for issue 53446
Closes #53446

Change-Id: I9c0e886e667a1988c061db9a998d59bd432c0595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335521
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-13 08:59:40 +00:00
Johnni Winther 13c335f7be [cfe] Add test for issue 53751
Closes #53751

Change-Id: I4b0a081ff904b2e2b097d47aaa09a04c8795e105
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335045
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-13 08:42:54 +00:00
Johnni Winther 1807debf84 [cfe] Add test for issue 53539
Closes #53539

Change-Id: Ib9453c9bbf3c39d8b4aaa13f72e7e954c3774e28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335445
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-11-10 13:56:28 +00:00
Johnni Winther c3cecaa791 [cfe] Add test for issue 53720
Closes #53720

Change-Id: I8c704ca47d089a2352414defd1e7fc6f96b52d03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335463
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-10 13:52:22 +00:00
Johnni Winther 6830cafbff [cfe] Add test for issue 53607
Closes #53607

Change-Id: I5b636d11c65b7fc9ef77a0dccbc4b44090112024
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335466
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-10 13:48:25 +00:00
Johnni Winther e15806ae42 [cfe] Add test for issue 52542
Closes #52542

Change-Id: I18105107faff642a6a0932eb0537ec02dfb5823b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335468
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-10 13:44:20 +00:00
Johnni Winther cd58ce5030 [cfe] Add test for issue 53740
Closes #53740

Change-Id: I14edfcd610366bd0f759030e1eb0dd057fbbaeae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335443
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-10 13:40:19 +00:00
Johnni Winther 1f86f34c5c [dartdevc] Add id-testing support in ddc
This adds id-testing support to dartdevc and uses it to add a
scope_test for the DartScope created for expression compilation.

Change-Id: I861092e17807190880bd20e4e39e012fbf0cbe53
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334220
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-11-10 10:49:56 +00:00
Johnni Winther 519b342cc6 [cfe] Erasure extension types in constants
Closes #53936

TEST=added testcases

Change-Id: I0457bed4c9ed3d242549bba328eabb2b03825227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334463
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-10 10:42:51 +00:00
Ömer Sinan Ağacan 75c975fe6d [dart2wasm] Remove stringref target
stringref target won't be used any time soon (probably ever). To help
with build times and avoid keeping it updated remove it for now.

Change-Id: I0df33b7ab2e19bae5090e8ea32ea6a3dc3751652
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334881
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-11-10 09:49:37 +00:00
Johnni Winther ad768fb480 [cfe] Handle generic extension types from dill
Closes #53780
Closes #53270

Change-Id: Ie1530e4d2d9bf77d17c1795fd514303e3e474b1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333826
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-10 06:57:50 +00:00
Johnni Winther e6fa7c9003 [cfe] Add test for issue 53822
Closes #53822

Change-Id: Iece860cce2f6e38e652ea95995e6c823cfdb5177
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334464
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-10 06:57:29 +00:00
Kallen Tu 166f83dc7e [cfe] Fix variance inference with interface subtype matching.
After switching over to NNBD, variance inference started failing because
we no longer used variance to subtype match.

This CL adds a null-aware subtype matching fn for the current algorithm.

Bug: https://github.com/dart-lang/sdk/issues/43419
Change-Id: Ifecc58a7537c0656f089cc3f8aca7fd4289be6d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334721
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-11-09 21:04:42 +00:00
Johnni Winther ea517c17a8 [cfe] Check getter/setter conflict on extension types
Change-Id: Ia9d6c65eef4ac82bb40a7111e2c418f08efb65b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330105
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-09 15:17:59 +00:00
Tess Strickland 262311772b Reland "[pkg/vm] Handle switch statements in unreachable code eliminator."
This is a reland of commit 92bf76d9e8

In the original CL, the changes to the UCE assumed all
SwitchStatements were exhaustive. Now if a SwitchStatement isn't
explicitly or implicitly (via a default case) exhaustive and no case
matches the tested constant, the SwitchStatement is properly removed.

In addition, if a guaranteed to match case is found, more than one
cases remain (thus the SwitchStatement is not removed or replaced with
the single case's body), and the default case is removed, then the
resulting SwitchStatement is marked as explicitly exhaustive, as this
serves as a signal to backends that they do not need to handle the
possibility of no case matching in the absence of a default case.

Original change's description:
> [pkg/vm] Handle switch statements in unreachable code eliminator.
>
> Namely, if the tested expression for a switch statement is constant,
> then we can remove any constant cases where the constants differ,
> and if all but a single case is removed, we can replace the switch
> with the case body.
>
> If constant functions are not enabled, then getters annotated with
> @pragma("vm:platform-const") are still evaluated with the constant
> function evaluation machinery, but only those and no others (including
> any functions called within an annotated getter). This way, functions
> can be annotated with @pragma("vm:platform-const") without having to
> rewrite them to be a single returned expression.
>
> TEST=pkg/vm/test/transformations/unreachable_code_elimination
>      pkg/vm/test/transformations/vm_constant_evaluator
>
> Issue: https://github.com/dart-lang/sdk/issues/50473
> Issue: https://github.com/dart-lang/sdk/issues/31969
> Change-Id: Ie290d2f1f469326238d66c3d9631f8e696685ff0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332760
> Commit-Queue: Tess Strickland <sstrickl@google.com>
> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TEST=pkg/vm/test/transformations/unreachable_code_elimination
     pkg/vm/test/transformations/vm_constant_evaluator

Issue: https://github.com/dart-lang/sdk/issues/50473
Issue: https://github.com/dart-lang/sdk/issues/31969
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try
Change-Id: I557ca933808012e670e306f2d880221a0d7dd670
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334224
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-11-09 11:11:09 +00:00
Johnni Winther 446881d53f [cfe] Update ast-to-text
Adds marker for InstanceAccessKind.Object and renames
'inline-class-member' to 'extension-type-member'.

TEST=existing

Change-Id: I087b48445e2794686c2f3db3d56dfbf7045f19fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334225
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-09 10:13:13 +00:00
Jens Johansen cd26ceeab1 [CFE] Micro-optimizations shaves off 1.42%
With a aot snapshot generated before this CL like this:

```
out/ReleaseX64/dart-sdk/bin/dart compile aot-snapshot \
  pkg/front_end/tool/_fasta/compile.dart
```

and then moved to `pkg/front_end/tool/_fasta/compile.org`,
then benchmarks run like

```
rm /path/to/other/checkout/pkg/front_end/tool/_fasta/compile.dart.dill ; \
  rm pkg/front_end/tool/_fasta/compile.aot ; \
  out/ReleaseX64/dart-sdk/bin/dart compile aot-snapshot \
  pkg/front_end/tool/_fasta/compile.dart && \
  out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart \
  --iterations=50 \
  --snapshot=pkg/front_end/tool/_fasta/compile.org \
  --snapshot=pkg/front_end/tool/_fasta/compile.aot \
  --arguments=/path/to/other/checkout/pkg/front_end/tool/_fasta/compile.dart \
  --filesize=/path/to/other/checkout/pkg/front_end/tool/_fasta/compile.dart.dill
```

(The other checkout is at 8b01baab71)

I get this:

```
Generated: [...]/pkg/front_end/tool/_fasta/compile.aot
Will now run 50 iterations with 2 snapshots.
......................................................................................................

Comparing snapshot 1 with snapshot 2
msec task-clock:u: -1.9077% +/- 0.5801% (-74.85 +/- 22.76)
page-faults:u: -2.6477% +/- 0.0391% (-2579.42 +/- 38.12)
cycles:u: -2.0459% +/- 0.6018% (-324680453.54 +/- 95498561.25)
instructions:u: -1.4202% +/- 0.0003% (-286466291.62 +/- 55229.41)
branch-misses:u: -3.0746% +/- 2.3469% (-1904933.80 +/- 1454106.83)
seconds time elapsed: -1.9144% +/- 0.5791% (-0.08 +/- 0.02)
seconds user: -1.8955% +/- 0.6479% (-0.07 +/- 0.02)
Scavenge(   new space) goes from 56 to 55
Notice combined GC time goes from 948 ms to 925 ms (notice only 1 run each).
```

So `instructions:u` being the most stable says a reduction of 1.42%,
time is in that range too (-1.9077% +/- 0.5801%), although in both
cases some of it is likely the number of new space GCs going from
56 to 55.

Change-Id: I0422af966f1902c50caa366cc2ad2cd7553c06d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333501
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-08 11:03:54 +00:00
Tess Strickland 08e15d7495 Revert "[pkg/vm] Handle switch statements in unreachable code eliminator."
This reverts commit 92bf76d9e8.

Reason for revert: broken tests on AOT trybots

Original change's description:
> [pkg/vm] Handle switch statements in unreachable code eliminator.
>
> Namely, if the tested expression for a switch statement is constant,
> then we can remove any constant cases where the constants differ,
> and if all but a single case is removed, we can replace the switch
> with the case body.
>
> If constant functions are not enabled, then getters annotated with
> @pragma("vm:platform-const") are still evaluated with the constant
> function evaluation machinery, but only those and no others (including
> any functions called within an annotated getter). This way, functions
> can be annotated with @pragma("vm:platform-const") without having to
> rewrite them to be a single returned expression.
>
> TEST=pkg/vm/test/transformations/unreachable_code_elimination
>      pkg/vm/test/transformations/vm_constant_evaluator
>
> Issue: https://github.com/dart-lang/sdk/issues/50473
> Issue: https://github.com/dart-lang/sdk/issues/31969
> Change-Id: Ie290d2f1f469326238d66c3d9631f8e696685ff0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332760
> Commit-Queue: Tess Strickland <sstrickl@google.com>
> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

Issue: https://github.com/dart-lang/sdk/issues/50473
Issue: https://github.com/dart-lang/sdk/issues/31969
Change-Id: I4340874793da19ce892a19bcf0542c24e0ee65d4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334600
Commit-Queue: Siva Annamalai <asiva@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-11-07 17:35:23 +00:00
Chloe Stefantsova ad298bf8e1 [cfe] Adjust the nullability of UP w.r.t. undetermined RHS
Closes https://github.com/dart-lang/sdk/issues/52726

Change-Id: I80c3c219738bb999a1a5939d95d3119d8b63332c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334441
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-07 15:21:37 +00:00
Jens Johansen 7826f6da4b [CFE] Benchmarker tool fixes
Benchmark tool now knows about, and warns about, the perf tools scaling
and adds a verbose gc run.

Change-Id: I4db98cd817bbddbc17e966768ef708f3d5e1e790
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333460
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-07 13:13:46 +00:00
Tess Strickland 92bf76d9e8 [pkg/vm] Handle switch statements in unreachable code eliminator.
Namely, if the tested expression for a switch statement is constant,
then we can remove any constant cases where the constants differ,
and if all but a single case is removed, we can replace the switch
with the case body.

If constant functions are not enabled, then getters annotated with
@pragma("vm:platform-const") are still evaluated with the constant
function evaluation machinery, but only those and no others (including
any functions called within an annotated getter). This way, functions
can be annotated with @pragma("vm:platform-const") without having to
rewrite them to be a single returned expression.

TEST=pkg/vm/test/transformations/unreachable_code_elimination
     pkg/vm/test/transformations/vm_constant_evaluator

Issue: https://github.com/dart-lang/sdk/issues/50473
Issue: https://github.com/dart-lang/sdk/issues/31969
Change-Id: Ie290d2f1f469326238d66c3d9631f8e696685ff0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332760
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-11-07 10:58:48 +00:00
Chloe Stefantsova 2b36affd2c [cfe] Report errors on duplicated interfaces in extension types
Closes https://github.com/dart-lang/sdk/issues/53791
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I41e214c3e2e6339c9b8baeaff727f95dc4089091
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334202
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-07 10:51:17 +00:00
Johnni Winther 807be18e97 [cfe] Add test for issue 53957
Closes #53957

Change-Id: I1bb3bcc74ba75d74ae2e0c7de47b5d02a9ba5267
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334461
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-11-07 10:38:15 +00:00
Chloe Stefantsova 2ea55d4301 [cfe] Ensure reporting all supertype conflicts in extension types
Closes https://github.com/dart-lang/sdk/issues/53799
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: Ic273541973de6377bb376f51850ec3d7d114c764
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334180
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-06 15:11:59 +00:00
Jens Johansen de7e3b7c5f [CFE] Better token leak tester
Instead of hard-coding a single Token name, find all subtypes of Token
and use that when searching for leaks.
We allow one instance of SyntheticToken because that's used in
`dummyToken`.
We fix the printing of retaining paths for fields.

Change-Id: Ic4d629ca08cae2307d4a550fb8b274f978c49b36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333823
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-06 14:37:38 +00:00
Johnni Winther 43db6c6ba8 [cfe] Split id-testing helpers
This prepares for adding id-test support in ddc.

Change-Id: I96d35b06e5e32f464cd487dc852ec114064afc9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334161
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-11-06 14:06:46 +00:00
Johnni Winther 3082602bf7 [cfe] Handle member access on extension type receivers
This updates the handling of member access on extension type receivers
to use the added `nonTypeVariableBound` and the `hasNonObjectMemberAccess`
properties.

The `nonTypeVariableBound` replaces the `resolveTypeParameterType`,
updated to taking the nullablity into account when going through
type variable bounds.

Change-Id: Ia2eb115c208350cdf011948177b15ebbc984fcac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333540
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-06 13:51:05 +00:00
Alexander Markov e7c8363900 [dart2wasm/tfa] Improve inference for binary int operations
Because of the special language rules (int +/-/* int = int),
static type for binary int operations can be more precise than
inferred result type (in case of dart2wasm, int binary operations
are declared as external methods returning num).

So, for dart2wasm it is useful to narrow result of a call by its
static type, if it is different from return type of the call target.

Also, this change fixes an incorrect static type which is
created during dart2wasm async* transformation.

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

Change-Id: Id6a5a2cffac47918c4e92f996267bf7fae713416
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333580
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-11-03 13:39:43 +00:00
Nate Biggs ad2708d071 [dart2js] Delete modular compilation step.
The Dart2JS team has agreed that this mode of compilation is no longer worth investing in at this time and its existence adds some overhead to other feature work so it is worth fully removing. In the future we may revisit this mode of compilation. Below is some more context for any future exploration in this space.

What didn't work with modular analysis:
- current modular analysis was computing impacts, which were dense (50% of the size of kernel)
- using it moved work to a modular phase, and cut Phase1 in half however end-to-end time was not better
- data overhead was very high
- it made it much harder to maintain invariants throughout the pipeline: the data is tightly coupled with the kernel AST, making it hard to make late modifications to the AST.

How to potentially make it better:
- make the data much more sparse
- make the data more independent from the kernel AST so that transformations are not breaking
- reduce the critical path in a more substantial way.

Note: We retain and ignore the commandline flags used for modular analysis in order to avoid breaking build pipelines that were passing them. We may remove these at a later date.

Change-Id: If574ce2358280ab5fedd89c62665328601e72e22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333360
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-11-03 00:11:50 +00:00
Chloe Stefantsova d003570453 [cfe] Include dill in propagating errors in redirecting factories
Redirecting factory chains may include a mix of source- and dill-
factory builders. The error propagation should work in that case too.

This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/332403/comment/14b70a92_c6e1a91e/

Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I74be2a47260c2c24c2fc871b7f1521546f056a03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333162
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-02 13:38:52 +00:00
Johnni Winther 12c4e22a4d [cfe] Handle various cases ExtensionType
Handles ExtensionType in inference of MapLiteral, inference of
ObjectPattern, and exhaustiveness.

TEST=tests/extension_type/*

Change-Id: I3284da2c69d875e192cf3f004ee1156e1aedd98b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333160
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-02 10:42:48 +00:00
Jake Macdonald 21b00d337b Add experimental release version for macros of 3.3.
Now that some basic support has landed internally, this will help to keep language versions more consistent for targets using macros, which will make SDK rolls easier.

Change-Id: Ifb9bb3def161edb3974cfc68271daad8a12707b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333200
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-11-02 09:38:12 +00:00
Chloe Stefantsova 3c4a74bc38 [cfe] Separate inference and error reporting in super parameters of extension type constructors
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/331048/comment/fbe89f66_bcf80d94/

Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I989cc3d3031e0bc4e66be1e28454443f918d20e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333003
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-01 12:52:30 +00:00
Chloe Stefantsova 8b01baab71 [cfe] Perform checks on factories of extension type declarations
Closes https://github.com/dart-lang/sdk/issues/53209
Closes https://github.com/dart-lang/sdk/issues/53140
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: Ia94b1e85d6775efc23bf732441fa66d4de1de515
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332403
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-01 10:14:49 +00:00
Chloe Stefantsova dd3705d5e8 [cfe] Allow extension types implement Object
This is a prerequisite to the implementation of
https://github.com/dart-lang/language/pull/3434

Closes https://github.com/dart-lang/sdk/issues/53840
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: Ib3bb5961cd8c4919cbc8c8ba37ac4d76fb72a3de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333000
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-01 09:26:30 +00:00
Johnni Winther 72f1591f29 [cfe] Use getTypeAsInstanceOf instead of getInterfaceTypeAsInstanceOfClass
The changes calls to getInterfaceTypeAsInstanceOfClass (et al.) to
getTypeAsInstanceOf to ensure that we take extension types into account.

Change-Id: I7d732cdae8494002b44561cb02c49d58dd0ba67b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332920
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-31 22:30:50 +00:00
Chloe Stefantsova c688bc8e6d [cfe] Implement relaxed rule on representation/implemented types
Closes https://github.com/dart-lang/sdk/issues/53867
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I1a286a8f507e92f85a79acb18d124d3322e1daa5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332961
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-10-31 13:17:58 +00:00
Johnni Winther 9732bcab6a [cfe] Add ClassMember.memberKind and .getTearOff
This adds the functionality to ClassMember that enables us to
fully compute the ExtensionTypeAccessTarget.

Change-Id: I62dd5e24f664c2edd70c2fe794f66595cc017173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332427
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-31 10:07:57 +00:00
Paul Berry d8732e9820 When field promotion fails, report all reasons via context messages.
Previously, if field promotion failed both because the language
version was less than 3.2, *and* for some other reason(s), the
analyzer and CFE only reported the other reason(s). The rationale was
that this was better than reporting just that the language version was
less than 3.2, because if a user upgraded their language version to
3.2 in an attempt to get field promotion to work, and *then* found out
that the property in question was unpromotable for some other reason,
that could be quite frustrating.

With this change, if field promotion fails both because the language
version is less than 3.2 and for some other reason, the analyzer and
CFE report *all* the reasons.

Change-Id: Ib5d3a4621273c1e80d66b66b456119f9053e18b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332485
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-10-30 21:31:51 +00:00
Nate Biggs 991f1aa248 [cfe] Add offset serialization to remaining Expression nodes without them.
Expressions missing offsets were:
- LogicalExpression
- ConditionalExpression
- Not
- BlockExpression
- Instantiation
- TypedefTearOff*

* I'm not sure how TypedefTearOff is actually being used, I don't see reference to it in the VM runtime. Unless the CFE lowers it before the VM gets it.

I also added a test on `binary.md` that ensures all expressions include a file offset in their serialized format. This can be expanded to statements if offsets are added to the remaining statement nodes without offsets.

TEST=Added binary_md_git_test.dart to ensure all expressions contain offset data going forward.


Change-Id: Ieaf80545f388b209f76be44db86ef07e80c8ad66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331540
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-10-30 16:05:27 +00:00
Daco Harkes 3283d4e2cb [test] Delete merge conflict files
Introduced in https://dart-review.googlesource.com/c/sdk/+/290760.

Change-Id: Ibea3d1147e30d040cbf828c20ffe3bee69380a05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332682
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2023-10-30 12:36:38 +00:00
Johnni Winther f900eb95b7 Enable extension types in package:web and dart:js_interop
This uses the allowed_experiments.json to opt package:web and
dart:js_interop in to the inline-class experiment (the extension
types feature) for early access and development.

Change-Id: Ieb828b654f2320b147a3c48bbb4a142da1c18380
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332421
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-10-30 10:58:45 +00:00
Alexander Aprelev 6a464c9dee Revert "Expire 3.0.0 experiment flags."
This reverts commit 6f29e7fce4.

Reason for revert: broke g3 bot

Original change's description:
> Expire 3.0.0 experiment flags.
>
> TEST=Existing tests covers.
> Change-Id: I161eefdc28c74f63ba1ee926800a01eea03d9930
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331960
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Alexander Thomas <athom@google.com>

Change-Id: Ied6f612dc922824ffdadc4660898f3b859922ff5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332582
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Auto-Submit: Alexander Aprelev <aam@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-10-27 16:50:09 +00:00
Paul Berry 83af09021f Front end: Fix field promotion for extension type representation variable.
Update the type inference algorithm so that `FlowAnalysis.propertyGet`
is appropriately called when analyzing code that refers to the
representation variable of an extension type.

Flow analysis requires an arbitrary `Object` to represent the property
in question; this is later passed to
`OperationsCfe.isPropertyPromotable`. We use the synthetic
"representation field" (which is actually a `Procedure`) for this
purpose
(`ExtensionTypeRepresentationAccessTarget.representationField`).

Representation variables are considered promotable if they are public
(see
https://github.com/dart-lang/language/pull/3411). `OperationsCfe.isPropertyPromotable`
can tell if the representation variable is public by checking the name
of the synthetic representation field.

Fixes #53439.

Bug: https://github.com/dart-lang/sdk/issues/53439
Change-Id: I8f7ff8fcd8e5a43de419b8441951b52a555fda1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332480
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-27 16:34:30 +00:00
Lasse R.H. Nielsen 6f29e7fce4 Expire 3.0.0 experiment flags.
TEST=Existing tests covers.
Change-Id: I161eefdc28c74f63ba1ee926800a01eea03d9930
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331960
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-10-27 13:57:00 +00:00
Johnni Winther 219711e6ac [cfe] Use extension type members hierarchy to lookup members
Change-Id: Ife78479add65488f79c5c949a7472e9d7ea22928
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332401
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-27 12:23:20 +00:00
Johnni Winther 931e27753a [cfe] Support inherited combined member signatures
This add support for inherited combined member signatures, both from
source and from dill.

Change-Id: I163f2b30c3242ba98692d7e9b52ef93fd0d6a903
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332201
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-26 09:56:05 +00:00
Johnni Winther 4b2cf0744d [cfe] Add TypeDeclarationType and asInstanceOf
This add a common sealed superclass TypeDeclarationType for
ExtensionType and InterfaceType and uses it to add a common
asInstanceOf method to ClassHierarchy.

Change-Id: I7294e41069b063305c3bd4e384ff90614a3936a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331981
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-10-26 08:46:48 +00:00
Paul Berry bbfe9b1ec9 Kernel: Remove Procedure.isLoweredLateField flag.
This flag used to be used for field promotion (to ensure that lowered
late fields are promotable, provided that they are private and final
and don't have a name that conflicts with something else
non-promotable). However, as of
https://dart-review.googlesource.com/c/sdk/+/330168, the logic for
determining when a Procedure is promotable now operates solely by
checking for all the conditions that prevent promotability. Lowered
late fields are now promotable because there is no reason for them not
to be.

Change-Id: I15982acef6fe8c46334fb859306bca1417a2ca64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331207
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-25 20:47:26 +00:00
Paul Berry c23ac067eb Improve the behavior of "why not promoted" when field promotion disabled.
If the user attempts to promote a property, and their language version
does not permit field promotion, the "why not promoted" logic now
checks whether the language version is the sole reason for the failure
in property promotion. In other words, it checks whether the property
would have been promotable *if* field promotion had been enabled. If
it would, then the context message displayed to the user explains that
the property did not promote because field promotion is not supported
by the current language version.

However, if there is some secondary reason why the property failed to
promote (in other words, if the property would not have been
promotable even if field promotion had been enabled), then the context
message now favors the secondary reason.

Rationale: imagine a user is maintaining a package that doesn't yet
support SDK version 3.2, and that package contains some property
that's non-promotable both because the language version is prior to
3.2 *and* for some other reason (e.g., because the property isn't a
private field). It would be quite frustrating if the user saw a
context message suggesting that the property would be promotable in
SDK 3.2, and then went to a lot of effort to bump their minimum SDK
version, only to discover *after* the bump that the property is still
not promotable.

In the process of making this change, I discovered that the CFE
doesn't support field promotion in patch files. This is because patch
files aren't listed in `SourceLoader.sourceLibraryBuilders`, so the
logic in the `FieldPromotability` is never invoked for those
files. Since patch files are an artifact of SDK development, and will
never be used by end users, it doesn't seem worth going to extra
effort to add this support. However, I've taken care to make sure that
the "why not promoted" logic recovers gracefully in patch files (by
simply not generating a context message).

Change-Id: I6c0d1c0f4b8a7690f6f775408cb5e857b2dd7b03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330241
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-10-25 19:41:26 +00:00
Johnni Winther e06536af2e [cfe] Create combined member signature stub
This create a stub for combined member signatures from multiple
inherited non-extension type members and adds these to the
extension type declaration.

A sealed [TypeDeclaration] superclass is added to [Class] and
[ExtensionTypeDeclaration] to support accessing the enclosing type
declaration from a [Member].

TEST=existing

Change-Id: Ic01535d27a14187d37b00868e7e90fe73558b051
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331181
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-25 14:16:00 +00:00
Chloe Stefantsova 0e2ed5ab7a [cfe] Report an error on optional positional or named parameters in extension type declarations
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I49e813f9573b2b66950e8aae572591b65b62e2ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331260
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-10-25 10:26:38 +00:00
Chloe Stefantsova 255f260ede [cfe] Report error on await of extension type that is not a future
Closes https://github.com/dart-lang/sdk/issues/53207
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: Idad31c3286108aa3dc75b4b3d7f5364674641582
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331980
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-10-25 07:41:18 +00:00
Chloe Stefantsova 439b79fb80 [cfe] Report contravariant type variable use in extension types
Closes https://github.com/dart-lang/sdk/issues/53803
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I348f6c84aa61eddae306faa96a560b4960724462
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331242
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-10-24 13:43:35 +00:00
Chloe Stefantsova 75920dd24b [cfe] Report error on trailing comma in extension type declarations
Part of https://github.com/dart-lang/sdk/issues/53625
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I793ef6329d99b1a4e829491f454f42c2ede941b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331185
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-10-24 11:59:22 +00:00
Chloe Stefantsova 67d45616c6 [cfe] Report error on bottom type used as representation type
Closes https://github.com/dart-lang/sdk/issues/53824
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I79776eb4f8b736f518898adff1078461895269f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-10-24 10:28:09 +00:00
Jens Johansen 216d98555c [CFE] Mark strong/extension_types/inherited_representation_field as semiFuzzFailureOnForceRebuildBodies
Closes https://github.com/dart-lang/sdk/issues/53805

Change-Id: I093d32a9b2a9fbf26fef475e18a1fb67d575758e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331880
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-10-24 10:01:58 +00:00
Chloe Stefantsova 9e36a864ee [cfe] Report errors on super formal parameters in extension types
Closes https://github.com/dart-lang/sdk/issues/53212
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I4f209ab220bb0a47328a60d91e66a891d8fc1362
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331048
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-10-24 08:43:39 +00:00
Paul Berry 6c9dbb35b5 Front end: fix promotion of fields accessed through mixin applications.
When a field is declared in a mixin, the front end creates a synthetic
getter in the mixin application class that gets the value of the mixed
in field. So if a piece of code accesses the mixed in field through
the mixin application class rather than through the mixin directly,
the resolved member is the synthetic getter rather than a field.

In order to ensure that the field remains promotable even if it is
accessed through the mixin application, the logic in
`OperationsCfe.isPropertyPromotable` needs to be changed so that it
doesn't treat these synthetic getters as non-promotable. The old logic
was essentially this:

1. If the property is not private, it's not promotable.

2. Otherwise, if the property is listed in
   `FieldNonPromotabilityInfo.fieldNameInfo`, it's not
   promotable. (This happens either if the property is not promotable
   for an intrinsic reason, such as being a non-final field or a
   concrete getter, or if it has the same name as a non-promotable
   property elsewhere in the library).

3. Otherwise, if the property is a getter that was lowered from an
   abstract field, it's promotable.

4. Otherwise, if the property is a getter that was lowered from a late
   field, it's promotable.

5. Otherwise, the property isn't promotable. (This was intended to
   cover the case where the property is an abstract getter
   declaration).

(Although conditions 3 and 4 were tested first, since they are more
efficient to test).

It turns out that once conditions 1-2 have been ruled out, the
property must have been declared as a method (which is being torn
off), a private abstract getter, or a (possibly abstract) non-external
private final field. Of these three possibilities, only the last is
promotable. So this can be simplified to:

(conditions 1-2 as above)

3. Otherwise, if the property is a method tear-off, it's not promotable.

4. Otherwise, if the property is an abstract getter, it's not promotable.

5. Otherwise, the property is promotable.

This makes the logic easier to follow, since conditions 1-4 are now
all reasons for non-promotability (rather than a mix of promotability
and non-promotability reasons). It also conveniently addresses the
problem with fields accessed through mixin applications, since they
aren't excluded by any of conditions 1-4.

(We still test conditions 3 and 4 first, since they are more efficient
to test.)

Fixes #53742.
Fixes #53617.
Fixes #53436.

Change-Id: I64df269c2a4a0714f9be239d832b61f4fb6a1a43
Bug: https://github.com/dart-lang/sdk/issues/53742
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330168
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-10-23 20:24:34 +00:00
Johnni Winther e35faa28d8 [cfe] Lookup representation field using ExtensionTypeDeclaration.procedures
Change-Id: Ie9c45b048126b1778794bf9bc58d53ba22aeff4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330803
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-10-19 14:23:29 +00:00
Johnni Winther d252bb11a3 [cfe] Add representation field to ExtensionTypeDeclaration
This adds the representation field of an extension type declaration
as an abstract getter in the ExtensionTypeDeclaraiton marking it as
a ProcedureStubKind.RepresentationField

These are never used as interface targets and are therefore skipped
in the type flow analysis.

TEST=existing

Change-Id: Ie645e63e0995a31895e985a2025dccb1476d16bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330782
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-19 10:15:25 +00:00
Mayank Patke 580384a28e [dart2js] Group modular and global kernel transformations.
This CL reorganizes our collection of kernel transformations into
"modular" and "global" ones. Modular (phase 0a) transformations are
those that can be run on each library before we have "linked" the full
program AST. Global (phase 0b) transformations are those that are run
over the full program AST.

Although we colloquially refer to multiple transformations of each kind,
there is actually a single modular (resp. global) `Transformer`, which
merges all the required transformations into a single AST pass.

Change-Id: I8f53cba6fc9a8aab106188ec3597ab194dd0cde0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330170
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2023-10-18 22:32:43 +00:00
Chloe Stefantsova ffd43b214e [cfe] Report errors on zero or more than one representation fields
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I1009241a0a09a92c0e5b22b3848482b87392a72b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331061
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-10-18 14:54:25 +00:00
Chloe Stefantsova be36f24d90 [cfe] Report error on representation type modifiers and missing type
This CL addresses some of the failures reported in
https://github.com/dart-lang/sdk/issues/53074

Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I2b23a9d0c095856139563f9e500e88bebadc1ce3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331042
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-10-18 11:15:05 +00:00
Chloe Stefantsova 871d0b1b71 [cfe] Update UP for the case of extension and interface types
Change-Id: I968cc9c8ab38c944716c1a5f392e8cc4a732c1b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330801
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-10-18 10:37:32 +00:00
Brian Quinlan b04c5a433e Adds tests and documentation for print line ending behavior
Bug:https://github.com/dart-lang/sdk/issues/53161
Change-Id: I3f13af3cb852b3656341922b9656ec91fc413eed
Tested: documentation + unit test only
CoreLibraryReviewExempt: Only adds documentation and adds a unit test to verify existing behavior
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323426
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-10-17 22:10:38 +00:00
Chloe Stefantsova c658b463f4 [cfe] Update UP for the case of two extension types
Closes https://github.com/dart-lang/sdk/issues/53290
Closes https://github.com/dart-lang/sdk/issues/53730

Change-Id: Ic3b720898b5877e3ab122cb904f0e9dbb9c63caa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330422
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-10-17 09:38:26 +00:00
Paul Berry 5fedeeb0d6 Front end: fix "why not promoted" messages for field promotion and mixins.
The front end handles mixin applications by synthesizing new fields
and procedures in the mixin application class to reflect the fields
and procedures from the mixin.

In order to ensure that the appropriate "why not promoted" context
messages are created for these synthesized fields and procedures,
entries need to be created for them in the
`FieldNonPromotabilityInfo.individualPropertyReasons` map.

Note that the source locations for these synthesized fields correspond
to the declaration of the mixin application rather than the original
field or procedure; to find the original field or procedure we use
`Procedure.stubTarget`.

Change-Id: Ib20d2514cb5aad8f95b93d26ad0e3917f1613db3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330246
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-10-13 17:17:49 +00:00
Johnni Winther 54b588a373 [cfe] Mark implicit enum constructors as synthetic
Closes #53615

TEST=existing

Change-Id: Ic2ad21787e62c8051dc2020cc15d61195f512b80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330440
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-10-13 15:28:46 +00:00
Johnni Winther f87142fdc2 [kernel] Add ExtensionTypeDeclaration.procedures
This adds a list of `Procedure`s to `ExtensionTypeDeclaration`. This is
meant to model representation fields and combined member signatures
computed from inherited non-extension type members.

These are not meant to be handled by the backends. The combined
member signature can be the interface target of an `InstanceInvocation`
expression but will always have a `.memberSignatureOrigin` value from
one of the original class members.

TEST=existing

Change-Id: I87768ed75a3c7126b0a30f8ccf06e46678c56db6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330301
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-10-13 07:42:29 +00:00
Jonas Termansen d2400d3def [cfe] Remove language version from unreleased experiment errors.
Unreleased experiments have no language version even though we pretend
they have the current language version. However, it's problematic to
mention the current language version in the error messages as the errors
go into the expectation files. It's a problem that we need to update an
unknowable amount of files whenever we bump the version, so it's much
better to omit the current language version from these error messages.

This change is part of the effort to make it possible to easily bump
tools/VERSION without unexpected issues whenever tests have to have
their pinned language versions updated as well.

Bug: b/30474526
Change-Id: Ia58b6ae002000511cea98ed83d256505deb986dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330108
Commit-Queue: Jonas Termansen <sortie@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-10-12 13:15:42 +00:00
Jens Johansen 73466729f3 [vm] Pass offset and script uri for expression compilation
This CL passes the offset and uri of the file (here called a script uri
as opposed to a library uri, the two will be different if we're in a
part) when doing expression compilation.

This CL only passes the data, but doesn't actually use it.
Future CL(s) will use this data to calculate the static type of
available variables which is needed for an upcomming feature.

TEST=Existing tests.
CoreLibraryReviewExempt: Not changing SDK APIs.
Change-Id: I67ead461ab4bb9341424e693946f3e4afe35ce92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329322
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-10-12 10:22:38 +00:00
Chloe Stefantsova 9beea1a044 [cfe] Avoid converting nominal to structural variable builders
Previously the nominal variable builders were created in all cases and
then converted to structural if that was required. It induced some
unnecessary type substitutions and complicated the logic behind the
builders. This CL introduces NominalVariableBuilder and
StructuralVariableBuilder as two possible subclasses of
TypeVariableBuilderBase, and the appropriate builders are created from
start.

This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/312264

Change-Id: I4e40de158201462dcef96b75445b8f179e1f75b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330081
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-10-12 09:52:29 +00:00
Chloe Stefantsova 7be0e438d9 [cfe] Adjust nullability of ExtensionTypes
The nullability of ExtensionType is affected by the representation type.

Change-Id: I2eb0aa7ee26caf97c2bc9c2bdec58369f5b598f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329920
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-10-12 08:31:24 +00:00
Paul Berry 0b0f9d4b91 Use switch expressions in WhyNotPromotedVisitor classes.
Change-Id: I5cffa6624585c5bd47129f709d7b6ac09e9a16c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328322
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-10-11 14:39:23 +00:00
Johnni Winther 9a4c9100ae [kernel] Add DartType.extensionTypeErasure
This renames ExtensionType.typeErasure and adds it to DartType. This also fixes the extension type erasure for when extension types are used in the arguments of an extension type.

DartType.extensionTypeErasure can be used by backends to easily
access the type without extension types for any type.

TEST=pkg/kernel/test/extension_type_erasure_test.dart


Change-Id: Ia49d273ed85111e3ae822720860a3e0be5ea0252
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329960
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-10-11 13:51:22 +00:00
Johnni Winther 9e3635c790 [cfe] Add token_leak_dart2js_test
This uses `token_leak_test.dart` to check that we can compile dart2js
without leaking tokens.

Change-Id: I78a419d722a4b017f1bc1e77933f8f54b4cff175
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330061
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-10-11 10:08:43 +00:00
Johnni Winther dbe761130a [cfe] Add ExtensionTypeMembersNode(Builder)
This builds a model of the extension type members and checks for
member conflicts.

Change-Id: Ia7dd4250184bed6f6da5e2dd05652fdf1d65c7dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329903
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-11 08:45:04 +00:00
Johnni Winther 96ae2c3cad [cfe] Reset EnumConstantInfo.argumentsBeginToken
This avoids leaking Token through EnumConstantInfo.argumentsBeginToken
and allows us to verify that no leaks occur when compiling the sdk.

Change-Id: I0168471fbc6609147c671204d119d161833e7c5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329904
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-10-11 07:38:13 +00:00
Johnni Winther eaa308fbef [cfe] Avoid Token leak through ConstructorReferenceBuilder.name
This changes ConstructorReferenceBuilder.name to use TypeName, thereby
avoiding the leak of Token through Identifier.

Change-Id: I7f84830dda97ebaa51a5a6c44cfda232e0c03174
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329901
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-10-10 13:21:51 +00:00
Johnni Winther b55ce54d22 [cfe] Remove ParameterBuilder.metadata
These are handled through the body builder, and the MetadataBuilder
where left unhandled, leading to leaking of their tokens.

Change-Id: I16cd47bf4c7027f7a306782510e12b0100e1087a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329900
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-10-10 10:47:50 +00:00
Johnni Winther 5704936e7e [cfe] Remove Token leak through MetadataBuilder.beginToken
Change-Id: I067b308443c93e4d6359418a2803110c800c9af3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329604
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-10-10 10:47:50 +00:00
Alexander Markov 481f2b39fc [vm] Fix noSuchMethod forwarding stubs in mixin applications
TEST=pkg/front_end/testcases/no_such_method_forwarders/regress_*

Fixes https://github.com/dart-lang/sdk/issues/53677
Fixes https://github.com/dart-lang/sdk/issues/53676
Fixes https://github.com/dart-lang/sdk/issues/53656
Fixes https://github.com/dart-lang/sdk/issues/53640

Change-Id: I282a57a6aa4d3d55235ff0fb2c1d9b8470c49c93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329565
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-10-09 16:57:22 +00:00
Jonas Termansen e743910b18 Reland "Bump version to 3.3."
Please prefer not to revert this change. Any tests that fail are release
blockers and need to be approved and urgently fixed forward. Dart 3.2
has already been cut and the version number must be updated. It is
acceptable for rolls to be blocked until the release blockers have been
resolved as P0 issues.

Remove needless version number comment from experimental_features to
remove duplicated information and simplify version updates.

Update dartdoc to a version that supports 3.3.

Change-Id: I1a19aa86e185c99e61374665f18cf24c498935a5
Tested: CQ
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329588
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Jonas Termansen <sortie@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-10-06 19:00:58 +00:00
Ilya Yanok 85fd1b8f43 Revert "Bump version to 3.3."
This reverts commit 81aaf6c6c4.

Reason for revert: regression in G3: b/303734572

Original change's description:
> Bump version to 3.3.
>
> Remove needless version number comment from experimental_features to
> remove duplicated information and simplify version updates.
>
> Tested: CQ
> Change-Id: I864bfc44070136406e95fdaf4d83f491b2c95943
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329460
> Reviewed-by: Alexander Thomas <athom@google.com>

Change-Id: Ie7dca3106345ee7949ccd13ab4765998926c0abc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329603
Commit-Queue: Ilya Yanok <yanok@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-10-06 13:34:56 +00:00