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

Unified Diff: sdk/lib/_internal/compiler/implementation/closure.dart

Issue 18181009: Make closures in constructor initializers read type variables directly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add VM crash and modify test. 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/closure.dart
diff --git a/sdk/lib/_internal/compiler/implementation/closure.dart b/sdk/lib/_internal/compiler/implementation/closure.dart
index be3734afd2d038cb3a780b97248d6aba5a3a5121..6abb7bd1113721252116155b45b0f4946b600be3 100644
--- a/sdk/lib/_internal/compiler/implementation/closure.dart
+++ b/sdk/lib/_internal/compiler/implementation/closure.dart
@@ -494,7 +494,11 @@ class ClosureTranslator extends Visitor {
} else {
Element element = elements[node];
if (element != null && element.kind == ElementKind.TYPE_VARIABLE) {
- registerNeedsThis();
+ if (outermostElement.isConstructor()) {
+ useLocal(element);
+ } else {
+ registerNeedsThis();
+ }
}
}
node.visitChildren(this);
@@ -504,6 +508,9 @@ class ClosureTranslator extends Visitor {
Element element = elements[node];
if (Elements.isLocal(element)) {
useLocal(element);
+ } else if (element != null && element.isTypeVariable()) {
+ TypeVariableElement variable = element;
+ analyzeType(variable.type);
} else if (node.receiver == null &&
Elements.isInstanceSend(node, elements)) {
registerNeedsThis();
@@ -512,9 +519,7 @@ class ClosureTranslator extends Visitor {
} else if (node.isTypeTest || node.isTypeCast) {
TypeAnnotation annotation = node.typeAnnotationFromIsCheckOrCast;
DartType type = elements.getType(annotation);
- if (type != null && type.containsTypeVariables) {
- registerNeedsThis();
- }
+ analyzeType(type);
} else if (node.isTypeTest) {
DartType type = elements.getType(node.typeAnnotationFromIsCheckOrCast);
analyzeType(type);
@@ -545,11 +550,13 @@ class ClosureTranslator extends Visitor {
void analyzeTypeVariables(DartType type) {
type.forEachTypeVariable((TypeVariableType typeVariable) {
- useLocal(typeVariable.element);
// Field initializers are inlined and access the type variable as
// normal parameters.
- if (!outermostElement.isField()) {
+ if (!outermostElement.isField() &&
+ !outermostElement.isConstructor()) {
registerNeedsThis();
+ } else {
+ useLocal(typeVariable.element);
}
});
}

Powered by Google App Engine
This is Rietveld 408576698