| 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);
|
| }
|
| });
|
| }
|
|
|