This is a re-fix of dartbug.com/21912, which I previously fixed
incorrectly. Previously, our approach to avoiding infinite loops when
comparing types was to maintain a set of typedefs being expanded on
the stack, and prune the comparison whenever an attempt was made to
expand a typedef that was already being expanded. However, this was
too strict, since there are legal (non-circular) types which invole
expanding a given typedef in reentrant fashion; we can't prune these
types without producing incorrect semantics. An example (from the bug
report) is the type of f in the code below:
typedef T Function2<S, T>(S z);
Function2<Function2<A, B>, Function2<B, A>> f;
The solution is to maintain the list of typedefs being expanded inside
each FunctionTypeImpl object (and InterfaceTypeImpl object) rather
than on the stack during the comparison; this allows us to distinguish
the situations where we need to prune (those having to do exclusively
with expansion of a typedef) from the situations where we shouldn't
prune (those having to do with substitution of a type parameter).
A beneficial side effect of this change is that code that interacts
with types no longer needs to worry about typedef circularities, since
the circularities will automatically be pruned while exploring the
type definitions. This simplifies the implementation of
isAssignableTo, isSubtypeOf, operator==, and hashCode. (Note,
however, that code still needs to cope with circularities in the
inheritance hierarchy).
BUG=dartbug.com/21912
R=brianwilkerson@google.com
Review URL: https://codereview.chromium.org//1143003007
Previously there was a problem with type variables referenced inside
a closure inside a field initializer, like so:
class Foo<T> {
var field = () => T;
}
The type variable cannot be accessed on 'this' because the closure is
created before 'this'. It also cannot be accessed as a parameter.
It is now properly treated as an unboxed free variable, and at
closure creation the value is taken from the constructor parameter
holding the type variable.
As with everything else during constructor build-up, the type variables
are now held in the IR builder's environment. It has proven to be a
robust way of doing things so far.
This simplifies the IR builder's role in this. The builder will not
detect how a type variable should be accessed (i.e. "if inside
a closure inside a field..."). If the type variable is in the
environment that's the one it will use, otherwise it defaults to
extract it from the receiver object.
Also, the closure conversion phase now detects type variables
mentioned in "on T catch()" clauses.
BUG=
R=karlklose@google.com
Review URL: https://codereview.chromium.org//1158693003
"x is Foo" will become getInterceptor(x).$isFoo
Testing against a type with type arguments is still a giveup().
This test always works, but is not very fast. For instance, testing
against an int should be "typeof x === 'number' && Math.floor(x) === x".
Following an offline discussion with Karl, the plan is to rewrite
'is'-checks to more fine-grained tests in a CPS optimization pass,
probably the type propagator.
Concretely, we plan to introduce IR nodes like TypeOfTest, FloorTest,
InstanceofTest, etc, which optimization phases can introduce under the
right circumstances. That way, the code generation phase remains simple.
BUG=
R=karlklose@google.com
Review URL: https://codereview.chromium.org//1144163004
This CL adds the implementation of all null-aware operators to dart2js. In
particular:
* a?.b: represented as 'isConditional' in the Send ast, and dispatched
separately by the semantic visitor using visitIfNotNull* methods.
* a ?? b: represented as an operator, and dispatched separately by the semantic
visitor using the `visitIfNull` method.
* a ??= b: represented as a compound operator.
All except 2 tests are passing with the SSA backend (those 2 tests fail for
unrelated reasons). I've marked the CPS ir tests as failing for now.
BUG=
R=johnniwinther@google.com, paulberry@google.com, sra@google.com
Review URL: https://codereview.chromium.org//1151163004
Intestingly, the VM, dart2js/SSA and dart2js/CPS all fail the new test
in three different ways.
This CL fixed the SSA and CPS backends, and leaves a status line for
the VM.
When a constructor A redirects to B, it is B that should evaluate
declaration-site initializers (unless B also redirects).
Thus, this should happen after the arguments to B have been computed.
In SSA: Fields were initialized at A instead of B
(i.e. before redirect).
In CPS: Fields were initialized at both places, just horrible.
In VM: There seems to be a problem with redirecting constructors
called using super().
VM bug report: https://code.google.com/p/dart/issues/detail?id=23488
BUG=
R=floitsch@google.com
Review URL: https://codereview.chromium.org//1129693006
A new IR node CreateInvocationMirror has been introduced, which is
needed for creating calls to noSuchMethod. The main reason for this node
is that the JS constructor for Invocation objects require the internal
(minified) name of the target, which the builder does not know.
I don't think the IR pipeline should depend on the Namer, so the IR node
is preserved all the way to codegen.
R=floitsch@google.com, kmillikin@google.com
Review URL: https://codereview.chromium.org//1130813002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45678 260f80e4-7a28-3924-810f-c04153c831b5
This test did not work as a multitest, because the
deferred_redirecting_factory_lib1.dart imports the main file - it will not
find it after the splitting and renaming.
Luckily it is not strictly required for the test (though somewhat cleaner)
to have a multitest.
BUG=
Review URL: https://codereview.chromium.org//1127023003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45643 260f80e4-7a28-3924-810f-c04153c831b5
Since r44861, ElementBuilder is responsible for creating the
ConstantInstanceCreationHandle objects associated with
InstanceCreationExpressions. Since InstanceCreationExpressions may
appear inside annotations, we must make sure the ElementBuilder visits
all annotations. Previous to this change, it didn't visit function
annotations.
BUG=dartbug.com/23354
R=scheglov@google.com
Review URL: https://codereview.chromium.org//1125613003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45489 260f80e4-7a28-3924-810f-c04153c831b5