Index: lib/compiler/implementation/resolver.dart |
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart |
index 7d3eae2b4d500f482a329245e9f842c19d815ab9..e1216ba009f4d4b5e9c2dba14b76fc3d603fed32 100644 |
--- a/lib/compiler/implementation/resolver.dart |
+++ b/lib/compiler/implementation/resolver.dart |
@@ -1049,7 +1049,22 @@ class TypeResolver { |
// Use the canonical type if it has no type parameters. |
type = cls.computeType(compiler); |
} else { |
- type = new InterfaceType(cls, arguments); |
+ bool isMalformedType = false; |
+ for (Link<DartType> link = arguments; |
+ !link.isEmpty(); |
+ link = link.tail) { |
+ DartType dtype = link.head; |
karlklose
2012/10/10 07:19:33
dtype -> type. (The class is only called DartType
|
+ if (dtype is MalformedType) { |
+ isMalformedType = true; |
+ break; |
+ } |
+ } |
+ if (isMalformedType) { |
+ type = new MalformedType( |
+ new MalformedTypeElement(node, scope.element)); |
+ } else { |
+ type = new InterfaceType(cls, arguments); |
+ } |
} |
} else if (element.isTypedef()) { |
TypedefElement typdef = element; |
@@ -1066,7 +1081,13 @@ class TypeResolver { |
type = new TypedefType(typdef, arguments); |
} |
} else if (element.isTypeVariable()) { |
- type = element.computeType(compiler); |
+ if (scope.inStaticContext) { |
+ onFailure(node, MessageKind.CANNOT_ACCESS_TYPE_VARIABLE_IN_STATIC_CONTEXT, [element.name]); |
karlklose
2012/10/10 07:19:33
Long line.
|
+ type = new MalformedType( |
+ new MalformedTypeElement(node, scope.element)); |
+ } else { |
+ type = element.computeType(compiler); |
+ } |
} else { |
compiler.cancel("unexpected element kind ${element.kind}", |
node: node); |
@@ -2882,6 +2903,7 @@ class ConstructorResolver extends CommonResolverVisitor<Element> { |
abstract class Scope { |
final Element element; |
final Scope parent; |
+ bool get inStaticContext => false; |
Scope(this.parent, this.element); |
abstract Element add(Element element); |
@@ -2911,6 +2933,8 @@ class VariableScope extends Scope { |
Element localLookup(SourceString name) => null; |
String toString() => '$element > $parent'; |
+ |
+ bool get inStaticContext => element.inStaticContext();//parent.inStaticContext(); |
karlklose
2012/10/10 07:19:33
Remove code in comment.
|
} |
/** |
@@ -2968,6 +2992,8 @@ class MethodScope extends Scope { |
} |
String toString() => '$element${elements.getKeys()}'; |
+ |
+ bool get inStaticContext => parent.inStaticContext; |
} |
class BlockScope extends MethodScope { |
@@ -2993,12 +3019,7 @@ class ClassScope extends TypeDeclarationScope { |
ClassElement cls = element; |
Element result = cls.lookupLocalMember(name); |
if (result !== null) return result; |
- if (!inStaticContext) { |
- // If not in a static context, we can lookup in the |
- // TypeDeclaration scope, which contains the type variables of |
- // the class. |
- result = super.localLookup(name); |
- } |
+ result = super.localLookup(name); |
return result; |
} |
@@ -3035,13 +3056,8 @@ class PatchClassScope extends TypeDeclarationScope { |
if (result !== null) return result; |
result = origin.lookupLocalMember(name); |
if (result !== null) return result; |
- if (!inStaticContext) { |
- // If not in a static context, we can lookup in the |
- // TypeDeclaration scope, which contains the type variables of |
- // the class. |
- result = super.localLookup(name); |
- if (result !== null) return result; |
- } |
+ result = super.localLookup(name); |
+ if (result !== null) return result; |
result = parent.lookup(name); |
if (result !== null) return result; |
return result; |