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 part of resolution; | 5 part of resolution; |
6 | 6 |
7 abstract class TreeElements { | 7 abstract class TreeElements { |
8 AnalyzableElement get analyzedElement; | 8 AnalyzableElement get analyzedElement; |
9 Iterable<Node> get superUses; | 9 Iterable<Node> get superUses; |
10 | 10 |
(...skipping 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2311 if (!inInstanceContext) { | 2311 if (!inInstanceContext) { |
2312 // We report an error within initializers because `this` is implicitly | 2312 // We report an error within initializers because `this` is implicitly |
2313 // accessed when unqualified identifiers are not resolved. For | 2313 // accessed when unqualified identifiers are not resolved. For |
2314 // details, see section 16.14.3 of the spec (2nd edition): | 2314 // details, see section 16.14.3 of the spec (2nd edition): |
2315 // An unqualified invocation `i` of the form `id(a1, ...)` | 2315 // An unqualified invocation `i` of the form `id(a1, ...)` |
2316 // ... | 2316 // ... |
2317 // If `i` does not occur inside a top level or static function, `i` | 2317 // If `i` does not occur inside a top level or static function, `i` |
2318 // is equivalent to `this.id(a1 , ...)`. | 2318 // is equivalent to `this.id(a1 , ...)`. |
2319 bool inInitializer = enclosingElement.isGenerativeConstructor || | 2319 bool inInitializer = enclosingElement.isGenerativeConstructor || |
2320 (enclosingElement.isInstanceMember && enclosingElement.isField); | 2320 (enclosingElement.isInstanceMember && enclosingElement.isField); |
2321 MessageKind kind = inInitializer | 2321 MessageKind kind; |
2322 ? MessageKind.CANNOT_RESOLVE_IN_INITIALIZER | 2322 Map arguments = {'name': name}; |
2323 : MessageKind.CANNOT_RESOLVE; | 2323 if (inInitializer) { |
2324 element = reportAndCreateErroneousElement(node, node.source, kind, | 2324 kind = MessageKind.CANNOT_RESOLVE_IN_INITIALIZER; |
2325 {'name': node.source}, isError: inInitializer); | 2325 } else if (name == 'await') { |
| 2326 var functionName = enclosingElement.name; |
| 2327 if (functionName == '') { |
| 2328 kind = MessageKind.CANNOT_RESOLVE_AWAIT_IN_CLOSURE; |
| 2329 } else { |
| 2330 kind = MessageKind.CANNOT_RESOLVE_AWAIT; |
| 2331 arguments['functionName'] = functionName; |
| 2332 } |
| 2333 } else { |
| 2334 kind = MessageKind.CANNOT_RESOLVE; |
| 2335 } |
| 2336 element = reportAndCreateErroneousElement(node, name, kind, |
| 2337 arguments, isError: inInitializer); |
2326 registry.registerThrowNoSuchMethod(); | 2338 registry.registerThrowNoSuchMethod(); |
2327 } | 2339 } |
2328 } else if (element.isErroneous) { | 2340 } else if (element.isErroneous) { |
2329 // Use the erroneous element. | 2341 // Use the erroneous element. |
2330 } else { | 2342 } else { |
2331 if ((element.kind.category & allowedCategory) == 0) { | 2343 if ((element.kind.category & allowedCategory) == 0) { |
2332 element = reportAndCreateErroneousElement( | 2344 element = reportAndCreateErroneousElement( |
2333 node, name, MessageKind.GENERIC, | 2345 node, name, MessageKind.GENERIC, |
2334 // TODO(ahe): Improve error message. Need UX input. | 2346 // TODO(ahe): Improve error message. Need UX input. |
2335 {'text': "is not an expression $element"}); | 2347 {'text': "is not an expression $element"}); |
(...skipping 2798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5134 } | 5146 } |
5135 | 5147 |
5136 /// The result for the resolution of the `assert` method. | 5148 /// The result for the resolution of the `assert` method. |
5137 class AssertResult implements ResolutionResult { | 5149 class AssertResult implements ResolutionResult { |
5138 const AssertResult(); | 5150 const AssertResult(); |
5139 | 5151 |
5140 Element get element => null; | 5152 Element get element => null; |
5141 | 5153 |
5142 String toString() => 'AssertResult()'; | 5154 String toString() => 'AssertResult()'; |
5143 } | 5155 } |
OLD | NEW |