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

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

Issue 17262003: Fix type variables in closures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Handle is!. 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 35b227e9862e3c9d690735ce189511ff116007de..327267297d91e235daf9c8e86ee8df5103639a9a 100644
--- a/sdk/lib/_internal/compiler/implementation/closure.dart
+++ b/sdk/lib/_internal/compiler/implementation/closure.dart
@@ -509,6 +509,12 @@ class ClosureTranslator extends Visitor {
registerNeedsThis();
} else if (node.isSuperCall) {
registerNeedsThis();
+ } else if (node.isIsCheck || node.isIsNotCheck) {
ngeoffray 2013/06/18 08:00:43 Why isn't visiting the right hand side of the expr
karlklose 2013/06/18 11:05:00 It is not enough because we only recorded the depe
+ TypeAnnotation annotation = node.typeAnnotationFromIsCheck;
+ DartType type = elements.getType(annotation);
+ if (type != null && type.containsTypeVariables) {
+ registerNeedsThis();
+ }
} else if (node.isParameterCheck) {
Element parameter = elements[node.receiver];
FunctionElement enclosing = parameter.enclosingElement;
@@ -542,23 +548,12 @@ class ClosureTranslator extends Visitor {
visitNewExpression(NewExpression node) {
DartType type = elements.getType(node);
- bool hasTypeVariable(DartType type) {
- if (type is TypeVariableType) {
- return true;
- } else if (type is InterfaceType) {
- InterfaceType ifcType = type;
- for (DartType argument in ifcType.typeArguments) {
- if (hasTypeVariable(argument)) {
- return true;
- }
- }
- }
- return false;
- }
-
void analyzeTypeVariables(DartType type) {
if (type is TypeVariableType) {
useLocal(type.element);
+ if (outermostElement.isConstructor()) {
ngeoffray 2013/06/18 08:00:43 Why is it only for constructor? Please add a comme
karlklose 2013/06/18 11:05:00 Added comment and changed to !isField.
+ registerNeedsThis();
+ }
} else if (type is InterfaceType) {
InterfaceType ifcType = type;
for (DartType argument in ifcType.typeArguments) {
@@ -572,7 +567,7 @@ class ClosureTranslator extends Visitor {
if (outermostElement.isConstructor() || outermostElement.isField()) {
analyzeTypeVariables(type);
} else if (outermostElement.isInstanceMember()) {
- if (hasTypeVariable(type)) {
+ if (type.containsTypeVariables) {
registerNeedsThis();
}
}

Powered by Google App Engine
This is Rietveld 408576698