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 064a52e1e9d17b601b616bc2e70046c6282e69eb..feabe83347e25ce53eac07497ba532d5e05df2e0 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| @@ -3231,8 +3231,33 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { |
| compiler.internalError("Unresolved element: $constructor", node: node); |
| } |
| + |
| + // Compute the right target and type for redirecting generative and |
| + // factory constructors. |
|
ahe
2013/01/29 09:30:58
This should be done by the resolver. At least add
ngeoffray
2013/01/29 09:37:22
What would it take to move it to the resolver? Kar
karlklose
2013/01/29 12:37:00
Why do you think this belongs in the resolver (and
|
| FunctionElement functionElement = constructor; |
| - constructor = functionElement.redirectionTarget; |
|
ngeoffray
2013/01/29 10:23:35
@Peter: Why are we changing constructor here? The
ahe
2013/01/29 10:57:48
Because I didn't know better.
ngeoffray
2013/01/29 11:03:20
After talking to Karl, it looks like we would stil
|
| + if (functionElement.redirectionTarget != functionElement) { |
| + FunctionExpression functionNode = constructor.parseNode(compiler); |
| + Node body = functionNode.body; |
| + if (body != null && body.asReturn() != null && |
| + body.asReturn().isRedirectingFactoryBody) { |
| + // Lookup the type expression used in the body and substitute the type |
| + // variables with the call's type arguments in it. |
| + Return redirectionNode = body; |
| + TreeElements treeElements = |
| + compiler.enqueuer.resolution.getCachedElements( |
| + constructor.declaration); |
| + ClassElement targetClass = constructor.getEnclosingClass(); |
| + DartType targetType = treeElements.getType(redirectionNode.expression); |
| + Link<DartType> typeVariables = targetClass.typeVariables; |
| + Link<DartType> typeArguments = type.typeArguments; |
| + type = targetType.subst(typeArguments, typeVariables); |
| + } |
| + constructor = functionElement.redirectionTarget; |
| + } |
| + |
| + // TODO(karlklose): move this type registration to the codegen. |
| + compiler.codegenWorld.instantiatedTypes.add(type); |
| + |
| // TODO(5346): Try to avoid the need for calling [declaration] before |
| // creating an [HStatic]. |
| HInstruction target = new HStatic(constructor.declaration); |
| @@ -3491,8 +3516,6 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| // on type arguments. |
| generateRuntimeError(node, '$type is malformed: $reasons'); |
| } else { |
| - // TODO(karlklose): move this type registration to the codegen. |
| - compiler.codegenWorld.instantiatedTypes.add(type); |
| visitNewSend(node.send, type); |
| } |
| } |