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

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

Issue 11183053: Remove VariableScope, Scope.lexicalLookup and Scope.inStaticContext (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 7b1e16a22b57230ad74baebf16413c2259d1434c..ceec45aba30b8671eb5ba60714a9235bfa990c3e 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1346,9 +1346,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
void setupFunction(FunctionExpression node, FunctionElement function) {
- // If [function] is the [enclosingElement], the [scope] has
- // already been set in the constructor of [ResolverVisitor].
- if (function != enclosingElement) scope = new MethodScope(scope, function);
+ scope = new MethodScope(scope, function);
// Put the parameters in scope.
FunctionSignature functionParameters =
@@ -2955,6 +2953,8 @@ class ConstructorResolver extends CommonResolverVisitor<Element> {
MessageKind.CANNOT_RESOLVE, [name]);
} else if (e.kind === ElementKind.TYPEDEF) {
error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, [name]);
+ } else if (e.kind === ElementKind.TYPE_VARIABLE) {
+ error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, [name]);
} else if (e.kind !== ElementKind.CLASS && e.kind !== ElementKind.PREFIX) {
error(node, MessageKind.NOT_A_TYPE, [name]);
}
@@ -2975,27 +2975,9 @@ abstract class Scope {
return parent.lookup(name);
}
- Element lexicalLookup(SourceString name) {
- Element result = localLookup(name);
- if (result != null) return result;
- return parent.lexicalLookup(name);
- }
-
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
@@ -3065,7 +3047,7 @@ class BlockScope extends MethodScope {
* scope and inherited members are available, in the given order.
*/
class ClassScope extends TypeDeclarationScope {
- bool inStaticContext = false;
+ ClassElement get element => super.element;
ClassScope(Scope parentScope, ClassElement element)
: super(parentScope, element) {
@@ -3073,16 +3055,9 @@ class ClassScope extends TypeDeclarationScope {
}
Element localLookup(SourceString name) {
- ClassElement cls = element;
- Element result = cls.lookupLocalMember(name);
+ Element result = element.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) {
@@ -3090,8 +3065,7 @@ class ClassScope extends TypeDeclarationScope {
if (result !== null) return result;
result = parent.lookup(name);
if (result !== null) return result;
- ClassElement cls = element;
- return cls.lookupSuperMember(name);
+ return element.lookupSuperMember(name);
}
Element add(Element newElement) {
@@ -3103,7 +3077,6 @@ class ClassScope extends TypeDeclarationScope {
// TODO(johnniwinther): Refactor scopes to avoid class explosion.
class PatchClassScope extends TypeDeclarationScope {
- bool inStaticContext = false;
ClassElement get origin => element;
final ClassElement patch;
@@ -3118,13 +3091,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;

Powered by Google App Engine
This is Rietveld 408576698