Index: lib/compiler/implementation/resolver.dart |
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart |
index ef8c2274e9123266caef50952b78fc5b8ae411e7..ff6a54ecd610b011fb36807a34e0129b8e2fefdf 100644 |
--- a/lib/compiler/implementation/resolver.dart |
+++ b/lib/compiler/implementation/resolver.dart |
@@ -1130,6 +1130,11 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
DartType useType(TypeAnnotation annotation, DartType type) { |
if (type !== null) { |
+ if (type.element.isTypeVariable() && enclosingElement.inStaticContext()) { |
+ error(annotation, |
+ MessageKind.CANNOT_ACCESS_TYPE_VARIABLE_IN_STATIC_CONTEXT, |
+ [type.name]); |
+ } |
mapping.setType(annotation, type); |
useElement(annotation, type.element); |
} |
@@ -2841,8 +2846,6 @@ class BlockScope extends MethodScope { |
* scope and inherited members are available, in the given order. |
*/ |
class ClassScope extends TypeDeclarationScope { |
- bool inStaticContext = false; |
ahe
2012/10/02 07:50:25
This is great.
|
- |
ClassScope(Scope parentScope, ClassElement element) |
: super(parentScope, element); |
@@ -2850,13 +2853,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. |
- return super.localLookup(name); |
- } |
- return null; |
+ return super.localLookup(name); |
} |
Element lookup(SourceString name) { |