Commit Graph

417 Commits

Author SHA1 Message Date
Chloe Stefantsova fac280bd7e [cfe] Add ScopeProvider as an interface of Field
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I8a9cb883181a584ceac9aef6a863e135474026eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495960
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-04-20 05:24:58 -07:00
Chloe Stefantsova b43c8e8696 [cfe] Remove remaining casting getters from AST nodes
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/492101, where some part
of the casting getters was removed.

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

TEST=ci

Change-Id: I7eefc226ca2edeb10e80d2d110a72acb2b7770f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493681
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-14 02:29:57 -07:00
Johnni Winther 85991680ac [cfe] Include (super)-initializing-formal modifier in ast-to-text
This adds the initializer-formal and super-initializer-formal modifiers to the ast-to-text output.

These flags are used by backends, so we should expect when these are present.

Triggered by discussion on https://github.com/dart-lang/sdk/issues/62645

TEST=existing

Change-Id: I3eec128c912249bc907931bcf01b52c0ec1eda62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494080
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-04-09 06:22:54 -07:00
Chloe Stefantsova aebe572acb [cfe,vm,dart2bytecode] Rename Variable into VariableDeclaration
Part of https://github.com/dart-lang/sdk/issues/61572

TEST=ci

Change-Id: I2c11c354611d48e6b57146fc6f3403597d87c2a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/492101
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-04-02 09:33:54 -07:00
Jens Johansen 4d3d70af23 [kernel] Format kernel
Kernel sdk version was bumped from 3.6 to 3.12 in
https://dart-review.googlesource.com/c/sdk/+/487542 (and to `^3.12.0-0`
in https://dart-review.googlesource.com/c/sdk/+/487880) but the source
was never formatted.

This is, if nothing else, bad for reviews, where editing a file changes
the file in lots of places because of new formatting.

This CL is the result of running

```
out/ReleaseX64/dart-sdk/bin/dart format pkg/kernel/
```

but also updates the formatter version used by a source generator
(`pkg/front_end/tool/visitor_generator.dart`) so things agree.

Change-Id: I66e35d4f1e2d08cecc30fb314546cae78b49e99b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490082
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2026-03-24 06:00:44 -07:00
Johnni Winther ee75d1dfab [cfe] Add file offsets for FunctionNode in ast-to-text
This is in preparation for adding missing file offsets.

Change-Id: If122a650a06c9ddf3ae5b73bf75d2f65aea51852
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488482
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-03-17 06:22:14 -07:00
Chloe Stefantsova 67b3b0709f [cfe,vm,dart2bytecode] Rename Variable into BaseVariable, ExpressionVariable into Variable
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/487381/comment/3eb20545_b37553c4/

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

TEST=existing

Change-Id: I15c7438dcec3d412f3050d3d80517d5cff5b515f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487800
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-13 05:42:05 -07:00
Chloe Stefantsova ea1f4d474e [cfe] Introduce InternalSyntheticVariable internal AST node
The new node is generated in for-in loops with synthetic variables.

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

Change-Id: Icaa63097a145d07cdcfe21edc0487a47f90da8dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487060
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-12 01:51:31 -07:00
Chloe Stefantsova 1ef944b052 [cfe] Add CatchParameterBuilder
This CL adds `CatchParameterBuilder`, which builds
`CatchVariable`. `BodyBuilderIimpl` and `InferenceVisitorImpl` are
changed accordingly, to produce and handle `CatchParameterBuider`
instead of `FormalParameterBuilder` for the parameters of the catch
clause.

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

Change-Id: I713b55be7d73cdd221736b4facb85b764380761c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484581
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-03-03 04:17:23 -08:00
Chloe Stefantsova cf850ff4cc [cfe] Introduce CatchVariable Kernel AST node
`CatchVariable`s are supposed to be used as parameters of the `catch`
block. In the CL they are emitted under an experimental flag.

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

Change-Id: I6a486a63680fb484de7607fdebab8ba9dd975f5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482783
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-02-24 04:01:49 -08:00
Chloe Stefantsova 7b41ba12f8 [cfe] Handle variables captured by initialized of late variables
Field `contexts` is added to `VariableInitialization` nodes, which is
similar to that of `FunctionNode` nodes, indicating the variable
contexts the initializer captures variables from.

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

Change-Id: I8115545ea8a98f6d7827eb833384b29b1799db58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478365
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-02-10 04:07:31 -08:00
Chloe Stefantsova 01b47b5590 [cfe] Create internalThisVariable in Resolver, not BodyBuilder
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/475621/comment/3c2355f3_8ca3c92a/

Additionally, `CaptureKind.captured` is renamed to
`CaptureKind.directCaptured` as suggested in
https://dart-review.googlesource.com/c/sdk/+/475820/comment/cdb67c8c_c93196ba/

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

Change-Id: Ib96cb97025d7229d0b87db65149bbb045e5a69c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477980
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-02-05 01:53:20 -08:00
Chloe Stefantsova f474dd9b3e [cfe] Add 'this' variable to closure contexts
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I28c2b9c00d8748162012d184f3b909e8023b2ccf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475621
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-01-26 07:28:03 -08:00
Chloe Stefantsova 1fb8ef4ec2 [cfe] Add function parameters to closure contexts
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Ic70f9da9fbe22c7e3d59d603563655941e5f5260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472200
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-01-22 02:14:56 -08:00
Ben Konyi 364b36691c Reland "[ DDC / CFE ] Add support for allowing imports of unsupported libraries"
This reverts commit c616db31d2.

Reason for revert: Fix landed downstream in Flutter engine: https://github.com/flutter/flutter/pull/180127

Original change's description:
> Revert "[ DDC / CFE ] Add support for allowing imports of unsupported libraries"
>
> This reverts commit b5e60be49d.
>
> Reason for revert: broke Flutter web engine tests
>
> Original change's description:
> > [ DDC / CFE ] Add support for allowing imports of unsupported libraries
> >
> > This change adds support for allowing for imports of unsupported
> > platform-specific libraries when the
> > `--include-unsupported-platform-library-stubs` flag is provided to the
> > CFE.
> >
> > This flag sets the `includeUnsupportedPlatformLibraryStubs` property in
> > `TargetFlags`, which `Target`s can use to conditionally return different
> > `DartLibrarySupport` objects with different supported/unsupported
> > library sets.
> >
> > A `checkForUnsupportedDartColonImports` function has been added to
> > `Target` that uses the value of `dartLibrarySupport` to determine if
> > there's any unsupported library imports. This function is called after
> > the various transformation operations provided by the `Target`
> > implementation, meaning the import of an unsupported library specified
> > in `dartLibrarySupport` will now result in a compilation error (this
> > includes `dart:mirrors` imports for VM targets when mirrors are
> > disabled, which was previously handled by the VM itself).
> >
> > Related to https://github.com/dart-lang/sdk/issues/62125
> >
> > TEST=Tests added / modified
> >
> > Change-Id: Ife819b2e1a6d28f67d80aab6701cd23a1724aa4d
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465760
> > Reviewed-by: Nicholas Shahan <nshahan@google.com>
> > Reviewed-by: Johnni Winther <johnniwinther@google.com>
> > Commit-Queue: Ben Konyi <bkonyi@google.com>
>
> Change-Id: I0b59f00e55a2424f783351abd977eb38409ce01f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469100
> Reviewed-by: Nate Biggs <natebiggs@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

Change-Id: I1ae2eac675432286aebabea3c1f58caf35a27fbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469240
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2025-12-19 12:53:22 -08:00
Alexander Markov c616db31d2 Revert "[ DDC / CFE ] Add support for allowing imports of unsupported libraries"
This reverts commit b5e60be49d.

Reason for revert: broke Flutter web engine tests

Original change's description:
> [ DDC / CFE ] Add support for allowing imports of unsupported libraries
>
> This change adds support for allowing for imports of unsupported
> platform-specific libraries when the
> `--include-unsupported-platform-library-stubs` flag is provided to the
> CFE.
>
> This flag sets the `includeUnsupportedPlatformLibraryStubs` property in
> `TargetFlags`, which `Target`s can use to conditionally return different
> `DartLibrarySupport` objects with different supported/unsupported
> library sets.
>
> A `checkForUnsupportedDartColonImports` function has been added to
> `Target` that uses the value of `dartLibrarySupport` to determine if
> there's any unsupported library imports. This function is called after
> the various transformation operations provided by the `Target`
> implementation, meaning the import of an unsupported library specified
> in `dartLibrarySupport` will now result in a compilation error (this
> includes `dart:mirrors` imports for VM targets when mirrors are
> disabled, which was previously handled by the VM itself).
>
> Related to https://github.com/dart-lang/sdk/issues/62125
>
> TEST=Tests added / modified
>
> Change-Id: Ife819b2e1a6d28f67d80aab6701cd23a1724aa4d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465760
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

Change-Id: I0b59f00e55a2424f783351abd977eb38409ce01f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469100
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2025-12-18 09:47:11 -08:00
Ben Konyi b5e60be49d [ DDC / CFE ] Add support for allowing imports of unsupported libraries
This change adds support for allowing for imports of unsupported
platform-specific libraries when the
`--include-unsupported-platform-library-stubs` flag is provided to the
CFE.

This flag sets the `includeUnsupportedPlatformLibraryStubs` property in
`TargetFlags`, which `Target`s can use to conditionally return different
`DartLibrarySupport` objects with different supported/unsupported
library sets.

A `checkForUnsupportedDartColonImports` function has been added to
`Target` that uses the value of `dartLibrarySupport` to determine if
there's any unsupported library imports. This function is called after
the various transformation operations provided by the `Target`
implementation, meaning the import of an unsupported library specified
in `dartLibrarySupport` will now result in a compilation error (this
includes `dart:mirrors` imports for VM targets when mirrors are
disabled, which was previously handled by the VM itself).

Related to https://github.com/dart-lang/sdk/issues/62125

TEST=Tests added / modified

Change-Id: Ife819b2e1a6d28f67d80aab6701cd23a1724aa4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465760
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-12-17 09:30:38 -08:00
Chloe Stefantsova e1d5dc8c35 [cfe] Assign captured contexts to FunctionNodes
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Id6293f6300436d252a52e973cba6cd52cda48758
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468281
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-12-16 05:14:41 -08:00
Chloe Stefantsova 87032377ee [cfe] Use ExpressionVariable in ForInStatement and similar nodes
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I4f02718dc292b0e18f1fb4858ee31b4c645597a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467360
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-12-11 01:38:24 -08:00
Chloe Stefantsova 95df731257 [cfe] Use VariableInitialization in ForStatement and similar nodes
This change is similar to
https://github.com/dart-lang/sdk/commit/c97e2554ee3b21b0b0146ca41be969dd8531986d,
where ExpressionVariable was used in VariableGet and VariableSet.

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

Change-Id: Id9fa5302adcf8c773cec8478a31948b54c8393b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466720
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-12-08 04:56:51 -08:00
Chloe Stefantsova 6209d8dd0b [cfe] Implement trivial context allocation strategy for local variables
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I7569168e6595e88e2bda25a122f3b238c188b381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466080
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-12-05 06:59:29 -08:00
Johnni Winther 1a1d7da7a3 [cfe] Use InvalidInitializer
Change-Id: Id4e1df17a14955b58e8db50abefb3ac4bbf1eaf8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464686
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-11-27 05:15:04 -08:00
Johnni Winther 4338105c13 [kernel] Make InvalidExpression.message non-nullable
Change-Id: I0b88dfa01a8e2caae8631266310aa3b0a5f5e0bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464685
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-27 05:15:04 -08:00
Chloe Stefantsova c94482a3b5 [cfe] Add text serialization for VariableInitialization
This is a step towards better visualisation of the new variable nodes
emitted by the CFE.

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

Change-Id: If39f609627044b97967ed82683bbf49bb02edd5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464182
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-11-26 03:11:52 -08:00
Alexander Markov d1e27305f7 [kernel] Print 'const' flag of procedures
Change-Id: Iab43421596f649cccd26657d82d08696140ce105
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463503
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2025-11-21 03:17:14 -08:00
Chloe Stefantsova c97e2554ee [cfe] Make VariableGet and VariableSet abstract interfaces
This change is similar to
https://dart-review.googlesource.com/c/sdk/+/456620 and
https://dart-review.googlesource.com/c/sdk/+/458520 and prepares the
CFE to emit new variable nodes when the experimental flag is on.

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

Change-Id: I78cff188c3a94de337d7114c7496552733b2e208
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461421
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-11-14 03:09:49 -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 a03be0a31a [cfe] Enable CFE unit testing for closure context lowering
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Ie44241a3aae78ae766cf06e8da5dc5c167242591
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456280
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-10-21 07:04:46 -07:00
Chloe Stefantsova cad0aae004 [cfe] Introduce Kernel AST node for the closure expreiment
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Iee3c2a223f4c44f5528016082cf3a068b401d87d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454061
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-10-17 02:16:25 -07:00
Jens Johansen 1f845d1eb7 [CFE] Expression evaluation: Use dynamic get etc and fixup names to access private stuff when possible
For expression evaluation we want to be "more than dart" in that if for
instance we can see (in the debugger) that a List contains `B`s (even
if it's typed as containing `A`s) we'd like to be able to access things
on `B` (without manually having to cast to either `B` or `dynamic`).

Furthermore - when we in the debugger can see that it's a `B`, and that
`B` has, say, a field `_privateField` or a method `_privateMethod` we'd
like to be able to access that even if `B` is in another library.

This CL - for expression evaluation - makes dynamic accesses and calls
where we would normally issue a "missing getter" (etc) error, and tries
to create a `Name` so private access is possible.

Change-Id: I887318a50413e9a5f11ec685b27719edd312dca0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446260
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-08-26 00:27:19 -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
Johnni Winther a04c0d4221 [cfe] Include library of private names in ast-to-text
This adds the library reference of private names of other libraries in
the ast-to-text of member declarations. This prepares for a fix of the
library used for private constructor tear offs.

TEST=existing

Change-Id: I65a30f6446b6e2cd15291327babb7fcacb36c4ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434640
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-06-17 06:15:43 -07:00
Johnni Winther 0297cad118 [kernel] Avoid dereferencing unlinked nodes in ast-to-text
This uses [Reference] directly to avoid trying to dereference an unlinked
[Reference]. This is in preparation for
https://dart-review.googlesource.com/c/sdk/+/434640

Closes #50368

TEST=existing

Change-Id: Ic22349cfeb1a99d820f0a413522a647a1a375bfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435121
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-06-17 06:14:10 -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 b7aaf90246 [model] Mark erroneous constructors as such in the CFE
This allows to skip some apriori failing checks and avoid cascading
errors. Aditionally it instructs the verifier to not check the
erroneous constructors.

Change-Id: Ie96bbe84d02a96567b3deab65e15e0780a625d19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424820
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-04-26 07:38:44 -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
Johnni Winther a3953f12c7 [cfe] Include Procedure.isSynthetic in ast-to-text
In preparation for fixing #60490

TEST=existing

Change-Id: Iad3448a30de91e62f0d60bbaa9c425bc4706c799
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421100
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-10 00:59:49 -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 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
Kallen Tu 9ead08f053 [cfe] Local functions named _ are not in scope.
Local functions named `_` are treated the same as local wildcard variables.
They cannot be referred to.
This CL changes that behaviour.

Bug: https://github.com/dart-lang/sdk/issues/55655
Change-Id: Idbbe2a4f5b406d4499602e808f6541af6451fb31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371480
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2024-06-14 22:31:48 +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
Jens Johansen 8e168fc9f1 [kernel] ast-to-text: Print uri in more places
Constructors (say from a macro), typedefs (maybe from a part) and
FileUriExpression in general didn't write their file uri when different
from their surrounding container.

Change-Id: I70dc8cbb525a6fc2c1949e0d1fb1726ac19c6505
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368566
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-05-30 07:22:38 +00:00
Jens Johansen 1eaa749e0e [kernel/CFE] Remove unneeded default in switches
This CL removes the "default" case when the switch must be exhaustive
and is exhaustive without the default. Found by modifying the CFEs
constant evaluator.

Change-Id: Iaba27864315875257502be8e74fc2ce34f6ce54d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367900
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-05-23 09:32:49 +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
Chloe Stefantsova 8aa400bf5f [analyzer][cfe] Share the implementation of the Variance class
Part of https://github.com/dart-lang/sdk/issues/54902

Change-Id: Ie406b59baf3efdeaac577f5181320b28c5076068
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361781
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-04-10 13:08:55 +00:00
Chloe Stefantsova 4d9aeda9a8 [cfe] Use StructuralParameters in TypedefTearOff and TypedefTearOffConstant
Change-Id: I6b221f36065b78c985c8a216b1ac43f9e518bb3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358905
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-03-22 13:01:05 +00:00
Vyacheslav Egorov 3bb1ada6e6 [kernel] Improve readability of ast_to_text output for metadata
TEST=ci

Change-Id: Iacd5689ec3a4c7e06d4ae18ed1cea471ad8db7b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357141
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-03-12 20:08:10 +00:00
Chloe Stefantsova 88403d9c3e [cfe] Show nullability formula for extension types in textual output
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/350323 and
https://dart-review.googlesource.com/c/sdk/+/351141. It clarifies the
nullability markers shown in the .expect files.

TEST=existing

Change-Id: I248531dd892ea676935d5479c86e43ce8a87628a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350823
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-03-05 09:49:31 +00:00