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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/scope.dart

Issue 24091002: Emit a compile-time error when the name of a variable is referenced in the (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update co19 test expectations. Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of resolution; 5 part of resolution;
6 6
7 abstract class Scope { 7 abstract class Scope {
8 /** 8 /**
9 * Adds [element] to this scope. This operation is only allowed on mutable 9 * Adds [element] to this scope. This operation is only allowed on mutable
10 * scopes such as [MethodScope] and [BlockScope]. 10 * scopes such as [MethodScope] and [BlockScope].
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 Element localLookup(SourceString name); 36 Element localLookup(SourceString name);
37 37
38 static Scope buildEnclosingScope(Element element) { 38 static Scope buildEnclosingScope(Element element) {
39 return element.enclosingElement != null 39 return element.enclosingElement != null
40 ? element.enclosingElement.buildScope() : element.buildScope(); 40 ? element.enclosingElement.buildScope() : element.buildScope();
41 } 41 }
42 } 42 }
43 43
44 class VariableDefinitionScope extends NestedScope {
45 final SourceString variableName;
46 bool variableReferencedInInitializer = false;
47
48 VariableDefinitionScope(Scope parent, this.variableName) : super(parent);
49
50 Element localLookup(SourceString name) {
51 if (name == variableName) {
52 variableReferencedInInitializer = true;
53 }
54 return null;
55 }
56
57 Element add(Element newElement) {
58 throw "Cannot add element to VariableDefinitionScope";
59 }
60 }
61
44 /** 62 /**
45 * [TypeDeclarationScope] defines the outer scope of a type declaration in 63 * [TypeDeclarationScope] defines the outer scope of a type declaration in
46 * which the declared type variables and the entities in the enclosing scope are 64 * which the declared type variables and the entities in the enclosing scope are
47 * available but where declared and inherited members are not available. This 65 * available but where declared and inherited members are not available. This
48 * scope is only used for class declarations during resolution of the 66 * scope is only used for class declarations during resolution of the
49 * class hierarchy. In all other cases [ClassScope] is used. 67 * class hierarchy. In all other cases [ClassScope] is used.
50 */ 68 */
51 class TypeDeclarationScope extends NestedScope { 69 class TypeDeclarationScope extends NestedScope {
52 final TypeDeclarationElement element; 70 final TypeDeclarationElement element;
53 71
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 172
155 Element localLookup(SourceString name) => library.find(name); 173 Element localLookup(SourceString name) => library.find(name);
156 Element lookup(SourceString name) => localLookup(name); 174 Element lookup(SourceString name) => localLookup(name);
157 175
158 Element add(Element newElement) { 176 Element add(Element newElement) {
159 throw "Cannot add an element to a library scope"; 177 throw "Cannot add an element to a library scope";
160 } 178 }
161 179
162 String toString() => 'LibraryScope($library)'; 180 String toString() => 'LibraryScope($library)';
163 } 181 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698