| 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 Element operator[](Node node); | 8 Element operator[](Node node); |
| 9 Selector getSelector(Send send); | 9 Selector getSelector(Send send); |
| 10 DartType getType(Node node); | 10 DartType getType(Node node); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 return true; | 30 return true; |
| 31 })); | 31 })); |
| 32 // TODO(johnniwinther): Simplify this invariant to use only declarations in | 32 // TODO(johnniwinther): Simplify this invariant to use only declarations in |
| 33 // [TreeElements]. | 33 // [TreeElements]. |
| 34 assert(invariant(node, () { | 34 assert(invariant(node, () { |
| 35 if (!element.isErroneous() && currentElement != null && element.isPatch) { | 35 if (!element.isErroneous() && currentElement != null && element.isPatch) { |
| 36 return currentElement.getImplementationLibrary().isPatch; | 36 return currentElement.getImplementationLibrary().isPatch; |
| 37 } | 37 } |
| 38 return true; | 38 return true; |
| 39 })); | 39 })); |
| 40 assert(invariant(node, | 40 // TODO(ahe): Investigate why the invariant below doesn't hold. |
| 41 getTreeElement(node) == element || | 41 // assert(invariant(node, |
| 42 getTreeElement(node) == null, | 42 // getTreeElement(node) == element || |
| 43 message: '${getTreeElement(node)}; $element')); | 43 // getTreeElement(node) == null, |
| 44 // message: '${getTreeElement(node)}; $element')); |
| 44 | 45 |
| 45 setTreeElement(node, element); | 46 setTreeElement(node, element); |
| 46 } | 47 } |
| 47 | 48 |
| 48 operator [](Node node) => getTreeElement(node); | 49 operator [](Node node) => getTreeElement(node); |
| 49 | 50 |
| 50 void remove(Node node) { | 51 void remove(Node node) { |
| 51 setTreeElement(node, null); | 52 setTreeElement(node, null); |
| 52 } | 53 } |
| 53 | 54 |
| (...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2985 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, [name]); | 2986 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, [name]); |
| 2986 } else if (identical(e.kind, ElementKind.TYPE_VARIABLE)) { | 2987 } else if (identical(e.kind, ElementKind.TYPE_VARIABLE)) { |
| 2987 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, [name]); | 2988 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, [name]); |
| 2988 } else if (!identical(e.kind, ElementKind.CLASS) | 2989 } else if (!identical(e.kind, ElementKind.CLASS) |
| 2989 && !identical(e.kind, ElementKind.PREFIX)) { | 2990 && !identical(e.kind, ElementKind.PREFIX)) { |
| 2990 error(node, MessageKind.NOT_A_TYPE, [name]); | 2991 error(node, MessageKind.NOT_A_TYPE, [name]); |
| 2991 } | 2992 } |
| 2992 return e; | 2993 return e; |
| 2993 } | 2994 } |
| 2994 } | 2995 } |
| OLD | NEW |