The widget transformer doesn't handle widgets with optional positional
parameters and therefore doesn't provide locations in these cases.
For this reason we leave the location field nullable and don't null check
it on construction.
Close#43371
Change-Id: I2595eb215e8fab477ab0819b70e25d9fb921ed01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162187
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
InterfaceType's referring to unnamed mixin applications continuously
cause problems for backends since these might not correspond to
types supported at runtime. The LUB specification does not mention
how to handle these so it is valid skip these in the computation of
LUB.
Change-Id: I38f46bf43d5858dec473c26326b741cf36eb57d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145420
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
This adds support lowering the encoding of top-level/static fields
with initializers as if they were marked as late fields. This ensures
that LateInitialization is thrown if final fields are written to during
initialization.
Closes#42956
Change-Id: I488fdddd87ebd935a0cdaf82a724e9b87d5f91ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160724
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This adds a mechanism similar to that used in async functions where
exceptions are caught in the synthetic code and passed into the
generated body to be rethrow'n.
This ensures the exception is throw'n from the same place as the
original yield*, as per the spec.
Bug: https://github.com/dart-lang/sdk/issues/42466
Change-Id: I553dd89141985f6f30751913a1c8a62b1229af04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158543
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
The widget transformer would try to pass on the location injected
parameter in the factory constructor when calling constructors of its
own kind in constructor body. For instance
class Foo extends Widget {
factory Foo() => new Foo.internal();
Foo.internal();
}
would be transformed into
class Foo extends Widget {
factory Foo({Location loc}) => new Foo.internal(loc: loc);
Foo.internal({Location loc}) : super(loc);
}
This doesn't work if the constructor invocation is constant. For
instance:
class Foo extends Widget {
factory Foo() => const Foo.internal();
const Foo.internal();
}
which would be transformed into
class Foo extends Widget {
factory Foo({Location loc}) => const Foo.internal(loc: loc);
const Foo.internal({Location loc}) : super(loc);
}
Here the reading of the injected factory parameter [loc] is not a
valid constant, leading to a compile-time error during constant
evaluation.
To handle this, const constructor invocations within factories do
not pass on the location from the surrounding constructor but
uses their own. For instance:
class Foo extends Widget {
factory Foo() => const Foo.internal();
Foo.internal();
}
will be transformed into
class Foo extends Widget {
factory Foo({Location loc})
=> const Foo.internal(loc: const Location());
Foo.internal({Location loc}) : super(loc);
}
This does mean that these constant widgets will all have a
location based on the factory constructor declaration and _not_
one per invocation of the factory constructor.
Related to https://github.com/flutter/flutter/issues/63335
Change-Id: Ie3300d3ba81324d5fbd7fb6ab72b9d83d7afcf22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158395
Reviewed-by: Jens Johansen <jensj@google.com>
Adds a member signature origin to member signatures and includes
an additional reference to these in MethodInvocation, PropertyGet,
PropertySet, etc.
This enables the VM to bypass the member signatures when loading the
AST.
Change-Id: I5cae11f4434bc052d0ba0acf0670dd002c6f3df1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157498
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
All of the backends (dart2js, DDC, VM) were checking if the invocation
name was tagged with "set:" and appending "=" to the name if so.
Instead, we can simply have the CFE perform this logic at the callsite.
Note that the name of the setter itself is still unchanged. Backends may
still need to generate the correct name themselves when handling NSMs
via code paths other than instantiateInvocation.
Change-Id: Iae42c849d3557be3e3b77c3af6f3993347ba0b6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156142
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
Previously to unwrap a type in isTop method the declared nullability
was set to Nullability.nonNullable. This doesn't work for
intersection type because .withDeclaredNullability() doesn't work for
them. This CL introduces a method that simulates the removal of the
top-level nullability type constructor from a type term, and uses the
method in isTop to account for intersection types and other possible
similar cases in future.
Change-Id: I3e6f30b5d93850b2cf92475a89d09d6d9255089f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156193
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Tests are now run over entire libraries instead of their sub-trees
that are deemed to be ready for the serialization by the verifier.
The update revealed two scoping bugs. This CL fixes them as well,
namely the following:
* Result expression of a block expression should be in the scope of
the block. That is, the variables declared in the block are
visible in the result expression.
* Local function declarations should be visible in the blocks they
are declared in. Accidentally, the Bind combinator was used
instead of Rebind, resulting in local functions being visible in
their own bodies, but not in the blocks they are declared in.
Change-Id: I856045464caa934228d5f259a4d2d582e77deb88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155124
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
The future non-basic version is to include the following:
* adding missing annotations on nodes
* adding URIs and file offsets to the nodes
* adding nullability markers to types
* stylistic changes
* optimizations
* better surface syntax
* better error messages
Change-Id: If2fc51e4932d9043dd1719b766bd23ff4e0fc1ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154001
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Supplementary changes for handling Classes done in this CL are the
following:
* handling Supertypes
* handling Constructors
* handling remaining kinds of Procedure
* serializing AsyncMarker the same way as flags
* eliminating the need to wrap flags into IntLiteral
Change-Id: Id69c6e37f093cf80206f4657b649f79c75484775
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154000
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
The flags on the fields are serialized as lists of flag names,
allowing for any combination of the flags in any order. Similar
technique is used in this CL to serialize the flags on Procedures and
VariableDeclarations. This is in the contrast with the previous
approach for those nodes, when the flags were the part of the
serialized name of the node (such as "static-method" for static
Procedures or "final" for final VariableDeclarations).
Change-Id: I02eb5ac92f6273542f08f269aee8e6519d3085e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153766
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This CL adds round-trip serialization support for FunctionDeclarations
and the remining kinds of VariableDeclarations, completing the support
for statements. Additionally, the CL fixes a variable scope issue in
Catch clauses, namely that the exception and the stack trace variables
should be visible in the body.
Change-Id: I3843d491b85a65c4953d6fc10a59ecbde5017029
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153611
Reviewed-by: Johnni Winther <johnniwinther@google.com>
In addition to supporting the nodes, the notion of Binder is
reworked. It doesn't store the computed local distinct name on the
node itself now, as it's not always possible (which is the case of
LabeledStatement), but keep it in a map.
Change-Id: I04c08875cbcac3a547d62afbe5b17f023e6f1035
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153342
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Note: This is a reland of https://dart-review.googlesource.com/c/sdk/+/150343
Adds a new SDK hash to kernels and the VM which is optionally checked
to verify kernels are built for the same SDK as the VM.
This helps catch incompatibilities that are currently causing
subtle bugs and (not so subtle) crashes.
The SDK hash is encoded in kernels as a new field in components.
The hash is derived from the 10 byte git short hash.
This new check can be disabled via:
tools/gn.py ... --no-verify-sdk-hash
This CL bumps the min. (and max.) supported kernel format version,
making the VM backwards incompatible from this point back.
This also bumps the min. and current ABI version.
Bug: https://github.com/dart-lang/sdk/issues/41802
Change-Id: I2f85945045a603eb9dcfd1f2c0d0d024bd84a956
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152802
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
The handling of null shorting in the variable initializer interfered with
the declaration of the variable, making subsequent flow potentially
losing track of promotions.
Closes#42504
Change-Id: Idb17920ffe8746983825714f76160abcca54751b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152760
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This CL adds support for type inference on type aliased invocations of
factory constructors, redirected as well as non-redirected, and it adds
some tests using this feature.
Additionally, this CL resolves a couple of issues that arose when the
directory nonfunction_type_aliases was migrated to null-safety (by
means of two single line fixes, in 'usage*_test.dart').
Still missing: The shadow nodes should be eliminated in
_unaliasTypeAliasedConstructorInvocations and
_unaliasTypeAliasedFactoryInvocations, this will be done in a separate
CL.
Change-Id: Ic146bd16a02ca8f79c46b7df7c8dff7712f21189
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152740
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>