OLD | NEW |
---|---|
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 interface TreeElements { | 5 interface TreeElements { |
6 Element operator[](Node node); | 6 Element operator[](Node node); |
7 Selector getSelector(Send send); | 7 Selector getSelector(Send send); |
8 Type getType(TypeAnnotation annotation); | 8 Type getType(TypeAnnotation annotation); |
9 } | 9 } |
10 | 10 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 } | 153 } |
154 ClassElement defaultClass = defaultType.element; | 154 ClassElement defaultClass = defaultType.element; |
155 defaultClass.ensureResolved(compiler); | 155 defaultClass.ensureResolved(compiler); |
156 assert(defaultClass.resolutionState == ClassElement.STATE_DONE); | 156 assert(defaultClass.resolutionState == ClassElement.STATE_DONE); |
157 assert(defaultClass.supertypeLoadState == ClassElement.STATE_DONE); | 157 assert(defaultClass.supertypeLoadState == ClassElement.STATE_DONE); |
158 if (defaultClass.isInterface()) { | 158 if (defaultClass.isInterface()) { |
159 error(node, MessageKind.CANNOT_INSTANTIATE_INTERFACE, | 159 error(node, MessageKind.CANNOT_INSTANTIATE_INTERFACE, |
160 [defaultClass.name]); | 160 [defaultClass.name]); |
161 } | 161 } |
162 // We have now established the following: | 162 // We have now established the following: |
163 // [intrface] is an interface, let's say "MyInterface". | 163 // [interface] is an interface, let's say "MyInterface". |
Johnni Winther
2012/08/17 10:39:45
[intrface] refers to the local variable so we shou
Mads Ager (google)
2012/08/17 10:44:38
Reverted this change. What a horrible variable nam
| |
164 // [defaultClass] is a class, let's say "MyClass". | 164 // [defaultClass] is a class, let's say "MyClass". |
165 | 165 |
166 // If the default class implements the interface then we must use the | 166 // If the default class implements the interface then we must use the |
167 // default class' name. Otherwise we look for a factory with the name | 167 // default class' name. Otherwise we look for a factory with the name |
168 // of the interface. | 168 // of the interface. |
169 SourceString name; | 169 SourceString name; |
170 if (defaultClass.implementsInterface(intrface)) { | 170 if (defaultClass.implementsInterface(intrface)) { |
171 // TODO(ahe): Don't use string replacement here. | 171 // TODO(ahe): Don't use string replacement here. |
172 name = new SourceString(constructor.name.slowToString().replaceFirst( | 172 name = new SourceString(constructor.name.slowToString().replaceFirst( |
173 intrface.name.slowToString(), | 173 intrface.name.slowToString(), |
(...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2431 TopScope(LibraryElement library) : super(null, library); | 2431 TopScope(LibraryElement library) : super(null, library); |
2432 Element lookup(SourceString name) { | 2432 Element lookup(SourceString name) { |
2433 return library.find(name); | 2433 return library.find(name); |
2434 } | 2434 } |
2435 | 2435 |
2436 Element add(Element newElement) { | 2436 Element add(Element newElement) { |
2437 throw "Cannot add an element in the top scope"; | 2437 throw "Cannot add an element in the top scope"; |
2438 } | 2438 } |
2439 String toString() => '$element'; | 2439 String toString() => '$element'; |
2440 } | 2440 } |
OLD | NEW |