Chromium Code Reviews| 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..28fdfbec40365a479984919543a72d118eeb082d 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) { |
|
Johnni Winther
2013/06/18 06:00:09
Why not also [:node.isIsNotCheck:] ?
karlklose
2013/06/18 07:48:23
Of course. Thanks for catching this.
|
| + 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()) { |
| + 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(); |
| } |
| } |