Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2248)

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 12093019: Support type variables on redirecting factory constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698