Updated the ddc canary implementation to handle variance subtyping.
Variance subtyping is currently broken on DDC. This CL emits a runtime call to `addTypeParameterVariances` from `rti.dart` to annotate the type parameter variances of each interface that's appeared in type recipes. The rest of the subtyping algorithm already exists from the Dart2JS implementation, so the variance feature should be working correctly now in DDC with these changes and after the switch to canary by default.
Existing tests now pass: language/variance/variance_in_subtyping_test, language/variance/variance_inout_subtyping_test
Fixes https://github.com/dart-lang/sdk/issues/54367
Change-Id: I8483570184de61f2a6d365f89446720ef2349608
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338651
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
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>
We want to be able to emit variance information in DDC and this flag was gating the variance checking logic in `rti.dart`.
Set to `true` by default since we can't use the feature without the experiment enabled anyways.
Change-Id: I69a0691e9fbe6f0f355fc7319151c19bbffc1961
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341640
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Update source code in tests to be migrated to null safety. Tests are
still running in unsound null safety.
In most cases types are now inferred to be non-nullable so the code that
makes expressions to be seen as nullable now require `as dynamic` to
allow them to compile.
Update nullable inference logic to recognize `.toString()` on a String
as non-nullable in code that has been migrated to null safety.
Change-Id: Id0771cc5317e3dafbf10e766b80d2994752bacc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337700
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Some SDK only inline helper methods expect specific types passed to
them. These expectations can't be enforced by the type system and
everything is currently working properly. Extension methods may cause
confusion in the future so this change adds a bit more context to
the error messages just in case.
Issue: https://github.com/dart-lang/sdk/issues/49735
Change-Id: Idc620993d1a240fa5aaaccd4519433b04f0ba9ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335942
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
- In development mode (DDC) the extra null safety errors will be thrown.
- Remove extra code paths that called unsound helpers.
- Fix expectations in weak_null_safety_errors_test.dart.
Change-Id: I107c602b0ae38b13038e501564cba9b8cfc58e70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329568
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
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>
Adds simple method inlining for select patterns only in the dart:_rti
library as an optimization. This helps avoid chains of costly
accesses method calls that in the end simply perform a single
operation and return the result.
For example and snipet from the compiled SDK before:
```
if (_rti._isString(object)) {...}
```
and after:
```
if(typeof object == "string") {...}
```
Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: I90596294d35a8fd75d74014c6a12f6e8c726cfcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324571
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Always throw on `InvalidType` and `AuxiliaryType` in all `DartType`
visitors. These are not expected to exist at this stage in the
compilation.
Change-Id: I8486e4245d6eae895d9420ca64a216aa207af80e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327980
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Now that the `DartType` class hierarchy is sealed if-else chains over
different `DartType`s can be replaced with exhaustive switch
statements.
Ensures the coverage of all types and provides compile time errors
when new types are added without handling them.
Delete the awkward assertion logic that we had before.
Issue: https://github.com/dart-lang/sdk/issues/53566
Change-Id: Ia400b0dcddb569bb8123a5c1d9e7704f8930bb55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327982
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Now that the `DartType` class hierarchy is sealed if-else chains over
different `DartType`s can be replaced with exhaustive switch
statements.
Ensures the coverage of all types and provides compile time errors
when new types are added without handling them instead of the awkward
assertion logic that we had before.
Issue: https://github.com/dart-lang/sdk/issues/53566
Change-Id: Ia78d403610259ca80c30ef52b1c46e475463e277
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327981
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Now that the `DartType` class hierarchy is sealed if-else chains over
different `DartType`s can be replaced with exhaustive switch
statements.
Ensures the coverage of all types and provides compile time errors
when new types are added without handling them instead of the awkward
assertion logic that we had before.
Issue: https://github.com/dart-lang/sdk/issues/53566
Change-Id: If6228ee05cafbe89e49b137d5b1555dbb3447a56
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327021
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Now that the `DartType` class hierarchy is sealed if-else chains over
different `DartType`s can be replaced with exhaustive switch
statements.
Ensures the coverage of all types and provides compile time errors
when new types are added without handling them instead of the awkward
assertion logic that we had before.
Issue: https://github.com/dart-lang/sdk/issues/53566
Change-Id: I5624dd53e8cb6f88d10a713e11e1488c28d67698
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327020
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Now that the `DartType` class hierarchy is sealed if-else chains over
different `DartType`s can be replaced with exhaustive switch
statements.
Ensures the coverage of all types and provides compile time errors
when new types are added without handling them instead of the awkward
assertion logic that we had before.
Issue: https://github.com/dart-lang/sdk/issues/53566
Change-Id: I8b0274d00cfe77fe64c15647b19e75a222afdba8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326902
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
This CL introduces StructuralParameter and StructuralParameterType
classes. They are intended to replace TypeParameter and
TypeParameterType respectively where those were used as type
parameters defined by FunctionTypes. Previously, type parameters of
FunctionTypes were represented by TypeParameter objects with the
‘parent’ field set to null. By introducing StructuralParameter and
StructuralParameterType this CL unambiguously separates the two
notions of type parameters.
TEST=existing
Change-Id: Ida3feb7ad96a7b2acef55840eacba9e36bf2a3e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312264
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This splits visitors for (Tree)Visitor(1) into pure interfaces, mixins,
and a base class with the base implementation. This is a step towards
avoid having an accidental default implementation where a static error
would have been preferable.
This extract a ConstantReferenceVisitor(1) and its corresponding
DefaultMixin from the Visitor(1) interface.
TEST=existing
Change-Id: Ibc55bed9cff76581deaade91a10600c17fafc6dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325704
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
This splits visitors for Initializer, Expression, Statement, Member,
and MemberReference into pure interfaces and mixins with the base
implementation. This is a step towards avoid having an accidental
default implementation where a static error would have been preferable.
TEST=existing
Change-Id: I4aa243ce3b3436e05d6164c934df3c44119cd1fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325521
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
This splits ConstantVisitor(1) into a pure interface and a
ConstantVisitor(1)DefaultMixin with the base implementation. This is
a step towards avoid having an accidental default implementation where
a static error would have been preferable.
Also removes BodyVisitor1 which was unused.
TEST=existing
Change-Id: I265754e13e0ebcce5c154b16c7ee36854f4ce9fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325400
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
In 8f4e5c8194 the `DiagnosticReporter` was cached in
`DevCompilerTarget` which introduced a memory leak.
Unfortunately our weekly bot that looks for leaks has been out of
commission, but is now coming back online.
This CL fixes the leak by overwriting the field every time, meaing we
don't save a reference to the first one (which is a leak).
Maybe ideally we shouldn't save it as a field at all, but that's a
potential for another day.
Change-Id: Ic740a212c436c475688a1de73c55a2344301e688
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325260
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
There is no need to add a single type parameter to the type table
because it is already represented as a local variable in the scope
where it appears.
Change-Id: I4553d54304a2e3b82e856b8511fdce81cda0653e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324901
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Optimize repetitive calls to isSubtype with a caches to store pairwise
results.
There are currently two caches for sound and unsound results but in the
future that can be combined into a single cache once the library is
aware of error reporting. That single cache could stores "pass", "fail",
or "fails when sound mode but passes in unsound null safety".
Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: I49e5794703fd58f1b2bba50e426e25146800fbb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323707
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
This splits DartTypeVisitor(1) into a pure interface and a
DartTypeVisitor(1)DefaultMixin with the base implementation. This is
a step towards avoid having an accidental default implementation where
a static error would have been preferable.
TEST=existing
Change-Id: Ieea9a773a9b70897a2db10cff8d721831a702a8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324780
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>