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..b9715a7d96c1db8490cd57a307f2dbd4c1356024 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| @@ -3231,8 +3231,31 @@ 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 |
|
ngeoffray
2013/02/18 09:44:28
What's a redirecting generative constructor?
karlklose
2013/02/19 13:20:27
One that uses this(...), but they never actually e
|
| + // factory constructors. |
| FunctionElement functionElement = constructor; |
| - constructor = functionElement.redirectionTarget; |
| + if (functionElement.redirectionTarget != functionElement) { |
|
ngeoffray
2013/02/18 09:44:28
Shouldn't you get the redirectionTarget until it's
karlklose
2013/02/19 13:20:27
Yes. It does not matter currently, because we bail
|
| + FunctionExpression functionNode = constructor.parseNode(compiler); |
| + if (functionNode.isRedirectingFactory) { |
| + // Lookup the type expression used in the body and substitute the type |
| + // variables with the call's type arguments in it. |
| + Return redirectionNode = functionNode.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 +3514,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); |
| } |
| } |