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

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

Issue 17262003: Fix type variables in closures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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
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 ea7e34cbe7ec32e92d656cdbdc145f369345fe8f..bf3a374bf94a36be5a57218b39ae5b4a54a80c36 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -3255,13 +3255,29 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
member = closureClass.methodElement;
member = member.getOutermostEnclosingMemberOrTopLevel();
}
- if (isClosure && member.isFactoryConstructor()) {
- // The type variable is used from a closure in a factory constructor. The
- // value of the type argument is stored as a local on the closure itself.
- return localsHandler.readLocal(type.element);
- } else if (member.isConstructor() ||
- member.isGenerativeConstructorBody() ||
- member.isField()) {
+ bool isInConstructorContext = member.isConstructor() ||
+ member.isGenerativeConstructorBody() ||
+ member.isField();
+ if (isClosure) {
+ if (member.isFactoryConstructor()) {
+ // The type variable is used from a closure in a factory constructor.
+ // The value of the type argument is stored as a local on the closure
+ // itself.
+ return localsHandler.readLocal(type.element);
+ } else if (member.isFunction() ||
+ member.isGetter() ||
+ member.isSetter() ||
+ member.isConstructor() ||
+ member.isGenerativeConstructorBody()) {
+ // The type variable is stored on the "enclosing object" and needs to be
+ // accessed using the this-reference in the closure.
+ return readTypeVariable(member.getEnclosingClass(), type.element);
+ } else {
+ assert(member.isField());
+ // The type variable is stored in a parameter of the method.
+ return localsHandler.readLocal(type.element);
+ }
+ } else if (isInConstructorContext) {
// The type variable is stored in a parameter of the method.
return localsHandler.readLocal(type.element);
} else if (member.isInstanceMember()) {
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/closure.dart ('k') | sdk/lib/_internal/compiler/implementation/tree/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698