Commit Graph

294 Commits

Author SHA1 Message Date
Johnni Winther a04691a8a8 [kernel][Contexts] Serialize new local variables
This adds serialization of the new local variables, VariableStatement and VariableDeclaration. This prepares for replacing LegacyVariable with the new variables in all backends.

TEST=existing

Change-Id: I9bbebfbfd372042d6b7027f0fabd24c165699832
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506240
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-27 00:41:34 -07:00
Nate Biggs 3d2d6492c1 Add 'external-effect' pragma support to all the backends.
Call sites targeting a procedure annotated with `external-effect` will
not produce any code, including the argument which will not be
evaluated.

However, the single parameter will be treated as 'live' for the purposes
of any global analysis the backends do. This is useful for things like
protobuf shaking where a user may want to retain certain protobuf
messages without actually emitting the code that retains those messages.

Today this functionality is available internally in the vm and wasm SDK
libraries. dart2js has similar functionality represented via the
opaqueTrue and opaqueFalse booleans (which will cause conditional
branches to get shaken after analysis). This will replace dart2js's
opaque(True/False).

This also adds validation to the frontend to ensure a method annotated
with 'external-effect' is well-formed.

Change-Id: If1c4096673e655c58fe7638840a16125003e7809
Tested: Backend tests for codegen were added. A frontend test was added for the validation. A language test was added to confirm the behavior.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476020
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-04-27 09:42:38 -07:00
Johnni Winther 988cd0f9b7 [cfe][PrimaryConstructors] Add isRedirecting/SuperInitializer flags to InvalidInitializer
This adds isRedirectingInitializer and isSuperInitializer to the Initializer hierarchy and adds flags to InvalidInitializer to signal when the InvalidInitializer should be taking as a redirecting or super initializer. This allows us to avoid miscatergorizing such declarations when they are erroneous.

Part of #61700

TEST=existing

Change-Id: If0fabbda10b72304999a5380fce74f9e8fa91ca4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486180
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-03-09 03:36:55 -07:00
Alexander Markov 99929813b0 [vm,kernel] Add unique IDs for local functions in kernel AST
The unique IDs are assigned during VM-specific lowering transformation
and recomputed during TFA tree shaking.

The IDs are not assigned when local function AST nodes are created
as it makes certain AST transformations very fragile (e.g. moving
a sub-tree to another parent, cloning a tree to insert into another
member).

The IDs will be used to identify local functions within a member by
the VM and different compilers (dart2bytecode, modular AOT).

TEST=ci

Change-Id: Ifa5dc007322a0137776961d364bbf8565137b318
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-02 06:55:31 -08:00
Chloe Stefantsova 5ca6fc646d [cfe,vm] Add 'this' expression to super invocation nodes
This CL adds the field `thisExpression` to the Kernel AST nodes
representing invocations of methods, getters, and setters. The field
is initially populated with `ThisExpression` nodes, and eventually it
will be set to a `VariableGet` of a `ThisVariable` in the new variable
model.

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

TEST=existing

Change-Id: I9d8e96cfe5c392f93d041d8947883fc86189c142
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474320
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-01-22 03:08:21 -08:00
Johnni Winther 5bc2037cb0 [kernel] Implement InvalidInitializer
This updates the Initializer classes such that InvalidInitializer has a message and will throw at runtime, similar to InvalidExpression. All initializers have positions and only FieldInitializer and SuperInitializer have an isSynthetic field.

TEST=pkg/front_end/testcases/general/invalid_initializer.dart

Change-Id: Ic444bb1dc273b433ac70249240527d115deaa332
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463661
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-27 01:53:23 -08:00
Johnni Winther 6d70657fad [kernel] Add RedirectingFactoryInvocation
This adds an internal wrapper expression for redirecting factory invocations. This holds a reference to the original redirecting factory constructor along with the resulting invocation of the generative or factory constructor. The node is removed during constant evaluation and only available to backends through the pre-modular transformations.

TEST=existing

Change-Id: I35c19766117ab2942aefddb4ccebcd2df66babf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454820
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-10-28 03:03:44 -07:00
Chloe Stefantsova 433c0998d0 [cfe] Remove Nullability.legacy
TEST=existing

Change-Id: Id924e4ef64ddabc1986cb885f558382ff139b481
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436620
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-07-02 23:50:12 -07:00
Chloe Stefantsova 1117dce94d [model] Mark erroneously initialized optional parameters as such
This adds the flag isErroneouslyInitialized to the VariableDeclaration
AST node in Kernel. The flag is set to true whenever it is concluded
during compilation that the initializer contains errors is erroneous
for the parameter in any other way, for exaple, due to a type mismatch.

Change-Id: I1b3c9c662974fb9537ab4f89b58dd004979feebe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431862
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-06-02 02:14:27 -07:00
Johnni Winther 94c9dff1c5 [cfe] Add isInternalImplementation to Extension(Type)MemberDescriptor
This adds a flag to the member descriptors that allow us to skip these when building the name space for extensions and extension types from dill.

The late lowering of fields in dart2js is fixed to support lookup from dill.

Change-Id: Iacbd6451ac234767036dfe8f818c3ecbb693ced8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427720
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-05-12 00:26:25 -07:00
Chloe Stefantsova d2ad38a49a [model] Mention Constructor.isErroneous in binary.md
It wasn't added by oversite. Similar flags for Field and Procedure are
already included in binary.md.

Change-Id: I3f12f170734489bbc72e03f9d7dcfdeef28daa8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427760
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-05-09 05:12:11 -07:00
Chloe Stefantsova 669bcef1a6 [model] Introduce isErroneous flag on Members in Kernel
The flag is used to signal known issues with members, so that the
verifier could skip on checking assumptions for well-formed programs.

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

TEST=existing

Change-Id: I7cf1983035d26105ccfe2e7a844a9ba3108bfda2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420760
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-04-23 01:15:43 -07:00
Jens Johansen 6ad56c68dc [kernel] Remove NNBD compilation mode dummy from kernel binary
Also clean up some of the magic constants around this.

TEST=CI

Change-Id: Ie02df874cb30761d5ea08ae52c1507cf25318280
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416940
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-03-21 06:15:41 -07:00
Johnni Winther 06d938046f [kernel] Remove NonNullableByDefaultCompiledMode
and TargetFlags.soundNullSafety

TEST=existing

Change-Id: I5e28d3d187b0f84fa23130c042fd3c55b89c687c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413460
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-19 01:37:07 -07:00
Alexander Markov 8c1fa6d05b [tfa,aot,dart2wasm] Allow tree-shaking of extension type members independently of their tear-offs
ExtensionTypeMemberDescriptor.memberReference and
ExtensionMemberDescriptor.memberReference are now nullable.

TFA-based tree shaker can now set them to null when extension type
member is not used and removed but corresponding lowered tear-off is
still used and retained.

Front-end never sets them to null and requires non-null memberReferences
when consuming kernel.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter155624.dart
Fixes https://github.com/flutter/flutter/issues/155624

Change-Id: I71f98c02f4659ff72a8c1d7fc6c578e8b8e26d82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401382
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-12-18 06:10:31 -08:00
Jens Johansen 66d8d8d6b3 [kernel/CFE] Mark when a VariableDeclaration is a super initializing formal
Tested: Existing tests.
Change-Id: I3d5ccba75c346c7e0cf743b3c2d151428a6bca80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399662
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-12-10 13:59:10 +00:00
Johnni Winther 3ffde1e5ed [cfe] Handle Never in list/map pattern
Closes #56138

Change-Id: I0bb24b0de3178e3a565b300cb7b9e1dee6c21e80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396803
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-11-22 14:45:44 +00:00
Johnni Winther 69bc1e86fb [kernel] Remove Extension.isExtensionTypeDeclaration flag
This was only used for an early extension types experiment.

TEST=existing

Change-Id: Icb85c744bc2ff48aae713ef01271719d3657b664
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/376940
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-07-22 14:42:13 +00:00
Jens Johansen ad5fa7f5e4 [kernel] Fix ExtensionTypeDeclaration specification in binary.md
Change-Id: Ie7dfec81517a9ef9fbb2935c9a1eff8607d3be41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374360
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-07-03 13:23:51 +00:00
Kallen Tu 141bb5417b [kernel] Add isWildcard flag to VariableDeclaration.
Adds the `isWildcard` flag to variables. Will be using this for producing better errors.

TEST= Existing expectations tests for wildcards pass with new flag.
Bug: https://github.com/dart-lang/sdk/issues/55655
Change-Id: If2f7a5555e7cc26e84d1b1e63e4261c81a157d78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370062
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2024-06-10 19:33:39 +00:00
Johnni Winther ae03b57cbb [cfe] Remove .isNonNullableByDefault from package:kernel
This removes the .isNonNullableByDefault properties and similar from
the AST nodes in package:kernel. NNBD is now always enabled so these
properties are trivial.

TEST=existing

Change-Id: I75ca0551ac4b5910ea63530dd0c9c2e68bd01aff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366320
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-05-15 08:31:38 +00:00
Johnni Winther 63d2008355 [cfe] Make kernel AST and CompilerOptions use strong mode by default
TEST=existing

Change-Id: I8d8bc59dc742a7499338ea2d23a611696492603c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359222
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-04-05 07:45:08 +00:00
Johnni Winther c4724e5a89 [cfe] Add Throw.forErrorHandling
This adds a `forErrorHandling` to the `Throw` node. This is used that the `throw` is *not* present in the source code but added to ensure
correctness and/or soundness of the generated code.

This is used for instance in the lowering for handling duplicate writes
to a late final field or for pattern assignments that don't match.

In response to https://github.com/dart-lang/sdk/issues/53519

TEST=updated ast-to-text

Change-Id: Ie103829d98fda9cd7b64e9e3d893e77d1e86d7d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347900
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2024-02-19 12:12:02 +00:00
Johnni Winther 8a2f6495b3 [cfe] Add isImplicitCall to DynamicInvocation
This adds an ìsImplicitCall to DynamicInvocation which is set on
expression like `d()` where `d` has type dynamic, to distinguish
the for `d.call()`.

TEST=pkg/front_end/testcases/general/dynamic_call.dart

Change-Id: I73beb911bdb315a510c862e6d4876cf7673ec3c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346240
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-01-19 08:39:30 +00:00
Chloe Stefantsova 3eeba4a4e2 [cfe] Refactor FunctionNode.futureValueType into emitted value type
Previously we would encode the type of the value returned in `async`
functions as the field `futureValueType` on `FunctionNode`. For all
other kinds of functions, such as `sync`, `sync*`, and `async*`, that
field would be null. This CL renames `futureValueType` into
`emittedVAlueType`, and for functions of kinds `async`, `sync*`, and
`async*` that is expected to be the type of values emitted via
`return` or `yield` statements. For `sync` functions that field is
supposed to contain `null`.

In response to https://github.com/dart-lang/sdk/issues/54159

TEST=existing

Change-Id: I1efdbcc4e75d150f5618c7ca50cfe49a0e54fce6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341662
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-12-19 08:44:43 +00:00
Paul Berry 949f3af120 Remove kernel flag Procedure.isAbstractFieldAccessor.
This used to be used solely by field promotion, to recognize when a
getter arose from a declaration of an abstract field, so that abstract
fields would be promotable but explicitly declared abstract getters
would not be.

However, with the adoption of
https://github.com/dart-lang/language/issues/3328, both abstract
fields and abstract getters are now considered promotable, so there is
no longer any need to distinguish them.

Bug: https://github.com/dart-lang/language/issues/3328
Change-Id: Idc14512568eb0a11dae4e364df453d117adff2e3
Tested: standard presubmit bots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338643
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-12-14 18:06:52 +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
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
Nate Biggs 175c949398 [cfe] Fix more cases of kernel AST serializer missing file offset.
Dart2JS uses the file offset on these nodes to create JS source maps. We want to maintain these file offsets across the serialization layer when we compile from dill files rather than directly from sources.

This last CL resolves all diffs observed in test files in pkg/compiler/test/inference/data.

TEST=Updating tests for all of these in fasta offsets tests.

Change-Id: If84c7542b61c8d8b894b202c68841ccfe91dafa5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328080
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-09-27 22:12:58 +00:00
Nate Biggs af7cbd2a04 [cfe] Fix kernel AST nodes serialized format missing file offset.
Dart2JS uses the file offset on these nodes to create JS source maps. We want to maintain these file offsets across the serialization layer when we compile from dill files rather than directly from sources.

Dart2JS tests were serializing via `--test-mode` flag and thus had incorrect source locations for some stack traces.

TEST=Updating tests for all of these in fasta offsets tests.

Change-Id: I33862462fbff84d88f8c51bdeb1efc5771cfb8b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327160
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-09-25 21:07:10 +00:00
Johnni Winther 4c1a94c0d3 [cfe] Embed tearoff in Extension(Type)MemberDescriptor
This simplifies handle the constructor/member and its corresponding
tearoff as a pair. Also it prepare for supporting tearoff of
extension type constructors and methods with the same name.

TEST=existing

Change-Id: Iea6cbc0250c8df6bd0f825068c1f3e865d938427
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324202
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-09-11 13:35:10 +00:00
Nate Biggs a503edf481 [cfe] Fix kernel (de-)serialization missing field offset on FieldInitializer.
We are experiencing diffs in Dart2JS source maps in `--test-mode` which does a serialization round trip. JS that should map to default parameters is instead mapping to the surrounding `Constructor` member since the FieldInitializer's offset is getting dropped.

This is affecting any Dart2JS split action build since those all end of serialiaing and deserializing the kernel. Any other tools using this serialization would also be affected.

TEST=Existing/will add in follow up.

Bug: https://github.com/dart-lang/sdk/issues/53466
Change-Id: Ibeccf9153c78e6c358806c7ded4dbc2dea49d8e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325020
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-09-08 18:53:39 +00:00
Johnni Winther 1da590fc3f Fix type promotion of late final fields on DDC and dart2wasm.
When the CFE compiles code for DDC or dart2wasm, it lowers late final
fields to synthetic getters. In order to ensure that accesses to these
fields can still be type promoted, a flag is added to the kernel
`Procedure` class, to indicate that a getter was produced by lowering
a late final field. When deciding whether a property access is
promotable, the CFE checks this flag; if it's set, it treats the
getter like a field.

Includes a language test validating the fix.

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

TEST=tests/language/inference_update_2/late_field_test.dart

Change-Id: I98b81f04a3342d851060e5b2a7265323b93bb4e3
Bug: https://github.com/dart-lang/sdk/issues/53462
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324767
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-09-08 14:02:00 +00:00
Johnni Winther caafea0aee [kernel] Rename ExtensionType.instantiatedRepresentationType to typeErasure
To align with the specification.

TEST=existing

Change-Id: I7a9f21473c860b90f051bf9bc3361dfd7786c40c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320521
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-08-17 08:32:58 +00:00
Johnni Winther a76f4d5c34 [cfe] Rename InlineClass to ExtensionTypeDeclaration
This renames InlineClass to ExtensionTypeDeclaration, and InlineType
to ExtensionType. Members of extension type declarations are called
extension type members instead of extension type declaration members
for "brevity".

TEST=existing

Change-Id: I91ed62533ddd345644492f04dc3310d007460288
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316780
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-08-01 09:04:38 +00:00
Johnni Winther bf9ea56ff7 [kernel] Remove nodes used for the old 'extension-types' experiment
This removes ExtensionType, ExtensionTypeShowHideClause and
CallSiteAccessKind from package:kernel which where only used by the now
removed 'extension-types' experiment.

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

TEST=existing

Change-Id: I58d2e8b0a92ac61329ee161cc6884a2c0e6f87ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316420
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-07-27 10:47:08 +00:00
Johnni Winther 0c8ded72dc [cfe] Add FileUriConstantExpression
This adds FileUriConstantExpression, a subclass of ConstantExpression, to support correct file offset of annotations for augmentations and patches.
The FileUriExpression is used to carry the file uri of the expression
before constant evaluation.

TEST=general/patch_annotations

Change-Id: I0dc8a0cb97dd530fd1960785d38c2d5e4883c3dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311660
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-06-28 07:52:09 +00:00
Johnni Winther 7226c7245e [kernel] Remove RedirectingFactory node
Closes #28421
Closes #29169

TEST=existing

Change-Id: Iee7d84fadc10981648cb327589fd7aa15b9b3e12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308140
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-14 06:38:32 +00:00
Johnni Winther ccb21bd54b [kernel] Add RedirectingFactoryTarget to FunctionNode
This replaces the RedirectingFactoryBody with a dedicated
RedirectingFactoryTarget object on FunctionNode.

TEST=existing

Change-Id: I3cc8b9f8abf938c6d60fdbc91b1f4210686fc359
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307082
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-06-08 08:04:15 +00:00
Alexander Markov 5ff0821b27 [kernel,vm] First-class kernel serialization of FutureOrType and NullType
TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/52565

Change-Id: I9906f2d10c7ed51d11a0c402b51c8189ac3b6298
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306901
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-06-05 21:24:35 +00:00
Johnni Winther 13c4ad23c5 [kernel] Add SwitchStatement.expressionType
This adds the static type of the switch statement expression to
the AST to better support optimizations based on the possible
runtime values of the switch expression.

TEST=existing

Change-Id: Ief35b687150401100d8c96721a026e9f0911b3b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301063
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-05-08 07:39:02 +00:00
Johnni Winther 7914382b50 [cfe] Remove length check from map pattern matching
In response to https://github.com/dart-lang/language/pull/2960

TEST=existing expectation tests

Change-Id: I5c0d9070b98074c167dea0a0b9a0d576d4aa33d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291825
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-03-30 11:26:08 +00:00
Johnni Winther 2528bf8666 [kernel] Add VariableDeclaration.isHoisted
This flag is set when a variable declaration is moved earlier in
order to be available for subsequent code that couldn't contain
its declaration. For instance variables declared in patterns which
needs to be declared before the matching expressions that initialize
them.

TEST=existing expectations tests

Change-Id: I80ab1138f08f725f3e01905c1a57a1483f809328
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291820
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-03-30 07:13:40 +00:00
Johnni Winther 210275c1fe [cfe] Use AsExpression for AssignedVariablePattern lowering
The lowering previously used a PromotedCachableExpression, therefore
missing the needed check on assignment.

Closes #51432

Change-Id: I9e671326df25add9a8abea03d1e52b1be5740adc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289901
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-03-24 00:10:07 +00:00
Johnni Winther c62534fc03 [cfe] Clean up properties on Pattern classes
This removes the "unset" values and uses nullable types instead.
The names and uses of the pattern fields are normalized, using
`matchedValueType`, `requiredType` and `lookupType` consistently
between [Pattern] subclasses.

TEST=existing

Change-Id: Ic79ce17075aa8ce252e1c223b59bef660f32bb7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288704
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-03-16 11:43:58 +00:00
Johnni Winther a811db5bc6 [cfe] Change MapPattern.key to Expression
The key can only be an Expression but was unneedingly wrapped in
a ConstantPattern. Since the shared type analysis only handles
map pattern keys as expressions, the expected properties of
ConstantPattern were not set. Amongst these were the static type
of the key expression, which is know passed directly to the
handleMapPatternEntry method.

Change-Id: I705fc655e440d534ccc442c9c1359c377955b3b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288282
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-03-13 10:05:16 +00:00
Johnni Winther f17cf33c6d [kernel] Move Pattern nodes to package:kernel
These AST nodes were so far internal to the CFE, but since we need to
move the pattern lowering to the constant evaluator we need to support them in the AST defined in package:kernel.

TEST=existing

Change-Id: Ie6c5f0f8ad75a866c5d965fdf506bc869ffaf654
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288241
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-03-13 08:43:07 +00:00
Johnni Winther 04e6f4c282 [kernel] Add VariableDeclaration.isSynthesized
This adds an [isSynthesized] flag to the [VariableDeclaration] the
signal when the variable doesn't correspond to a variable in the
source code.

The name of a variable can only be `null` if it is synthesized.

Partially in response to
https://github.com/dart-lang/sdk/issues/51554

TEST=existing

Change-Id: I94591971f11da09d210c8b25a2d05e22ca05dc62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286961
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-03-10 11:13:36 +00:00
Alexander Markov e27923a5a0 [dart2js] Static weak references to method tearoffs
TEST=language/static_weak_reference_test
TEST=language/static_weak_reference_error_test

Bug: b/269223463

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I760476a7c81751f6c302f21251b525cb5c916c02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284489
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-03-02 20:04:19 +00:00
Johnni Winther fa0eb1eeec [cfe] Support implements clause on inline classes
Closes #51445

TEST=pkg/front_end/testcases/inline_class/implements.dart

Change-Id: I1214afd8fe8f87ca516be018129e1629c91af289
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284704
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-02-23 08:07:44 +00:00