That is, if a field has no declaration-site initializer and at least
one constructor in the class does not initialize it, then we add an
explicit null initializer for it.
BUG=
R=ahe@google.com
Review URL: https://chromereviews.googleplex.com/527827014 .
When visiting a generic function type in contravariant context, the
current variance bit would not be propagated to the inner visitor.
For example,
(<F>(T,F) => F) => int [bottom <: T <: String]
would erroneously map to:
(<F>(bottom,F) => F) => int
instead of:
(<F>(String,F) => F) => int
Generic function types cannot occur in contravariant position
using current Dart syntax, but it could possibly occur as an
intermediate type.
BUG=
R=ahe@google.com
Review URL: https://chromereviews.googleplex.com/521207013 .
When a class inherits two abstract members with the same name from
different supertypes, both members are now present the list returned
by ClassHierarchy.getInterfaceMembers. Previously, only one of the
member would be present.
This ensures that all override pairs can be detected, which in turn
is necessary for inserting covariance checks in strong mode.
Another change in this CL is that interface members are built
eagerly instead of on-demand. This makes the ClassHierarchy more
reliable when used for transformation, and easier to benchmark.
BUG=
R=kmillikin@google.com
Review URL: https://chromereviews.googleplex.com/520907013 .
Previously, we would generate a stub for a redirecting factory, but
the default parameter values were not correctly forwarded.
This could have been fixed by copying the default parameter values into
the stub, but this conflicts with modular compilation, since the
element model does not expose default parameter values, and we should
not rely on the AST of libraries not part of the current build unit.
Apart from fixing this bug, this is also more aligned with how all the
backends actually work.
R=kmillikin@google.com
Review URL: https://chromereviews.googleplex.com/513577013 .
Strong mode allows constant expressions to reference type parameters.
This requires constants to be canonicalized at runtime, but it is not
yet determined exactly how this feature will work in future versions
of the language.
For now, we work around it by replacing such types with 'dynamic'.
BUG=
R=kmillikin@google.com
Review URL: https://chromereviews.googleplex.com/516477013 .
Block expressions are expressions and so can be arbitrarily nested.
They can contain statements, including yield statements. The VM's
implementation of yield assumes that it can only occur when there are no
live intermediate values. It is not generally safe to allow
yield-containing block expressions to appear as arbitrary
subexpressions.
As a first step toward eliminating block expressions, this change
flattens the ones produced by the async transformation so that they can
only occur as the children of statements.
BUG=
R=asgerf@google.com
Review URL: https://chromereviews.googleplex.com/517457014 .
A mixin application C<T1 ... Tm> with D<T1 ... Tn> is canonicalized if
the Ts are distinct, unbound type variables. In all other cases, a new
class is created per mixin application.
Previously, all mixin applications were canonicalized in an overly
general way, causing type checking issues, and excessive duplication of
type parameters.
BUG=
R=kmillikin@google.com
Review URL: https://chromereviews.googleplex.com/511567015 .
The VM does not support function type parameters at the moment, but we
can erase them at the last minute, to enable testing of other parts of
strong mode.
This also disables error checking in the SDK since the VM's
patch files are not in strong mode.
BUG=
R=kustermann@google.com
Review URL: https://chromereviews.googleplex.com/518647013 .
The concept of a binary library file no longer exists.
A kernel file can contain any number of libraries, and some of these
libraries can be "external". To reference a class or member from
another build, the class or member must be declared in an external
library.
Members in an external library contain all their type information,
but have no body.
Classes in an external library have their hierarchy information
present, but are not guaranteed to contain all their actual members.
The idea is that references themselves don't really cross module
boundaries, but rather refer to a local definition whose body is
contributed from elsewhere, much like 'external' members in Dart.
A modular backend such as DDC should be able to compile from one of
these kernel files without needing to load auxiliary information from
summaries or other kernel files.
For whole program transformations or backends, a linking step, which
is not yet implemented, must merge classes and members in external
libraries based on their name.
External libraries share the same IR and binary format as ordinary
libraries. Transformations that affect the interface for a member
or class should transform the external libraries alongside with the
internal ones, ideally without needing to treat them any different.
R=kmillikin@google.com
Review URL: https://chromereviews.googleplex.com/516847013 .
For now the focus is on getting stacktraces to look right.
What that basically means is to include source positions for throws,
calls (in many forms).
Includes source file uri for libraries, field, classes and methods.
Methods and fields for instance needs it because of top-level
procedures that might be included via 'parts'.
Corresponding kernel-sdk change in review at
https://chromereviews.googleplex.com/516617014R=asgerf@google.com, kasperl@google.com
Review URL: https://chromereviews.googleplex.com/509247013 .
dartk and other command-line tools no longer rely on analyzer classes
like AnalysisContext or DartSdk, and instead use only the interface
defined in loader.dart.
The class AnalyzerLoader has been renamed to DartLoader.
The sharing of state in batch mode is now owned by loader.dart, so
dartk.dart does not deal with DartSdk and package_config.
Repository no longer has a package or SDK path. These concepts are
now specific to the Dart frontend. Consequently, loading a binary
file no longer relies on URI resolution.
The Repository class is now more clearly focused on linking symbolic
names to their IR objects, which for the time being is only
URI-to-library bindings, but should be extended to support linking
class and member references across different files and different
loaders.
BUG=
R=kmillikin@google.com
Review URL: https://chromereviews.googleplex.com/512907013 .
Fields getters and setters should be implicit whenever possible
to ensure JS compilers can easily control how they are generated.
However, it is still useful to be able to take control of the getter
or setter in the IR. We should just refrain from doing so for common
cases, where it can have significant code size impact in JS.
We can use this to insert checked setters for fields that override
a setter with an incompatible type, or whose type references a type
variable.
There are two changes to facilitate this:
- Fields have two flags indicating if the implicit getter and/or
setter should be generated. If not set, there can be an explicit
getter/setter for it in the same class.
- Interface targets that reference a field now go through one
level of indirection. This lets us update interface targets in
the IR, which is necessary for redirecting calls to an explicit
getter or setter.
BUG=
R=kmillikin@google.com
Review URL: https://chromereviews.googleplex.com/504357013 .
A single suite of test files is now shared among these configurations,
each with their own expected outputs:
- spec mode
- strong mode
- spec mode w/ type propagation
Although some tests are going to focus on a specific configuration,
for now it seems easier to maintain a single set of tests.
No additional tests have been added in this CL, but the intention
is to start adding more tests.
The baseline tests no longer contain any checked-in dill files.
To simplify dependencies, these tests do not rely on a patched SDK,
which means the async transformer cannot currently be tested with
this framework.
BUG=
R=kmillikin@google.com
Review URL: https://chromereviews.googleplex.com/507347013 .
Allocate contexts to hold captured variables. Rewrite captured variable
access to context access. Outside of a local function, this is a single
indirection through a named context. Inside a local function it requires
traversing (a statically known number of) parent links.
R=ahe@google.com
Review URL: https://chromereviews.googleplex.com/507717013 .
This lets us substitute different values for a type parameter depending
on the variance of its use site. For example:
(T) => T
can be substituted with [bottom <: T <: num] to get:
(bottom) => num
which is the best upper bound that doesn't use T.
This generalizes the existing substitution method, since it's
complicated enough that I don't want to maintain two versions of it.
BUG=
R=kmillikin@google.com
Review URL: https://chromereviews.googleplex.com/501577015 .