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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 10996039: Bring type variables into static scope, but produce compile-time error when they are used. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Just rebased Created 8 years, 2 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: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index 2e96dc00a63159e00123c75c8930762cef083154..e2c383c0b17ba2c20fcaea33fa43d9b3bfce0bad 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1176,6 +1176,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);
}
@@ -2820,18 +2825,6 @@ class Scope {
abstract Element localLookup(SourceString name);
}
-class VariableScope extends Scope {
- VariableScope(parent, element) : super(parent, element);
-
- Element add(Element newElement) {
- throw "Cannot add element to VariableScope";
- }
-
- Element localLookup(SourceString name) => null;
-
- String toString() => '$element > $parent';
-}
-
/**
* [TypeDeclarationScope] defines the outer scope of a type declaration in
* which the declared type variables and the entities in the enclosing scope are
@@ -2901,8 +2894,6 @@ class BlockScope extends MethodScope {
* scope and inherited members are available, in the given order.
*/
class ClassScope extends TypeDeclarationScope {
- bool inStaticContext = false;
-
ClassScope(Scope parentScope, ClassElement element)
: super(parentScope, element) {
assert(parent !== null);
@@ -2912,13 +2903,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);
- }
- return result;
+ return super.localLookup(name);
}
Element lookup(SourceString name) {

Powered by Google App Engine
This is Rietveld 408576698