Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| index 11146ddc8af0608bc83f9d347b4cd6e793bd0c8b..e035636619b1b7ecc55e52e4659d4f97f02cbeb0 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| @@ -3369,6 +3369,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| } |
| FunctionElement functionElement = constructor; |
| constructor = functionElement.redirectionTarget; |
| + |
| final bool isSymbolConstructor = |
| functionElement == compiler.symbolConstructor; |
| @@ -3381,6 +3382,26 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| message: 'Constructor Symbol.validated is missing')); |
| } |
| + bool isRedirected = functionElement.redirectionTarget != functionElement; |
|
ngeoffray
2013/05/30 08:23:14
Add this logic to the FunctionElement class or Ele
karlklose
2013/05/30 11:44:23
Done.
|
| + DartType expectedType = type; |
| + if (isRedirected) { |
| + FunctionExpression functionNode = functionElement.parseNode(compiler); |
| + if (functionNode.isRedirectingFactory) { |
| + // Lookup the type used in the redirection. |
| + Return redirectionNode = functionNode.body; |
| + TreeElements treeElements = |
| + compiler.enqueuer.resolution.getCachedElements( |
| + functionElement.declaration); |
| + ClassElement targetClass = functionElement.getEnclosingClass(); |
| + type = treeElements.getType(redirectionNode) |
| + .subst(type.typeArguments, targetClass.typeVariables); |
| + } |
| + functionElement = functionElement.redirectionTarget; |
| + } |
| + |
| + // TODO(karlklose): move this type registration to the codegen. |
| + compiler.codegenWorld.instantiatedTypes.add(type); |
|
ngeoffray
2013/05/30 08:23:14
Why is that needed here now, even in the case it's
karlklose
2013/05/30 11:44:23
This was a leftover from the old state of the buil
|
| + |
| var inputs = <HInstruction>[]; |
| // TODO(5347): Try to avoid the need for calling [implementation] before |
| // calling [addStaticSendArgumentsToList]. |
| @@ -3425,6 +3446,15 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| if (isListConstructor && backend.needsRti(compiler.listClass)) { |
| handleListConstructor(type, send, newInstance); |
| } |
| + |
| + // Finally, if we called a redirecting factory constructor, check the type. |
| + if (isRedirected) { |
| + HInstruction checked = potentiallyCheckType(newInstance, expectedType); |
| + if (checked != newInstance) { |
| + pop(); |
| + stack.add(checked); |
| + } |
| + } |
| } |
| visitStaticSend(Send node) { |