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 2939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2950 inConstContext = node.isConst(); | 2950 inConstContext = node.isConst(); |
2951 Node selector = node.send.selector; | 2951 Node selector = node.send.selector; |
2952 Element e = visit(selector); | 2952 Element e = visit(selector); |
2953 return finishConstructorReference(e, node.send.selector, node); | 2953 return finishConstructorReference(e, node.send.selector, node); |
2954 } | 2954 } |
2955 | 2955 |
2956 /// Finishes resolution of a constructor reference and records the | 2956 /// Finishes resolution of a constructor reference and records the |
2957 /// type of the constructed instance on [expression]. | 2957 /// type of the constructed instance on [expression]. |
2958 FunctionElement finishConstructorReference(Element e, | 2958 FunctionElement finishConstructorReference(Element e, |
2959 Node diagnosticNode, | 2959 Node diagnosticNode, |
2960 Expression expression) { | 2960 Node expression) { |
2961 // Find the unnamed constructor if the reference resolved to a | 2961 // Find the unnamed constructor if the reference resolved to a |
2962 // class. | 2962 // class. |
2963 if (!Elements.isUnresolved(e) && e.isClass()) { | 2963 if (!Elements.isUnresolved(e) && e.isClass()) { |
2964 ClassElement cls = e; | 2964 ClassElement cls = e; |
2965 cls.ensureResolved(compiler); | 2965 cls.ensureResolved(compiler); |
2966 if (cls.isInterface() && (cls.defaultClass == null)) { | 2966 if (cls.isInterface() && (cls.defaultClass == null)) { |
2967 // TODO(ahe): Remove this check and error message when we | 2967 // TODO(ahe): Remove this check and error message when we |
2968 // don't have interfaces anymore. | 2968 // don't have interfaces anymore. |
2969 error(diagnosticNode, | 2969 error(diagnosticNode, |
2970 MessageKind.CANNOT_INSTANTIATE_INTERFACE, [cls.name]); | 2970 MessageKind.CANNOT_INSTANTIATE_INTERFACE, [cls.name]); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3033 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, [name]); | 3033 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, [name]); |
3034 } else if (!identical(e.kind, ElementKind.CLASS) | 3034 } else if (!identical(e.kind, ElementKind.CLASS) |
3035 && !identical(e.kind, ElementKind.PREFIX)) { | 3035 && !identical(e.kind, ElementKind.PREFIX)) { |
3036 error(node, MessageKind.NOT_A_TYPE, [name]); | 3036 error(node, MessageKind.NOT_A_TYPE, [name]); |
3037 } | 3037 } |
3038 return e; | 3038 return e; |
3039 } | 3039 } |
3040 | 3040 |
3041 /// Assumed to be called by [resolveRedirectingFactory]. | 3041 /// Assumed to be called by [resolveRedirectingFactory]. |
3042 Element visitReturn(Return node) { | 3042 Element visitReturn(Return node) { |
3043 Expression expression = node.expression; | 3043 Node expression = node.expression; |
3044 return finishConstructorReference(visit(expression), | 3044 return finishConstructorReference(visit(expression), |
3045 expression, expression); | 3045 expression, expression); |
3046 } | 3046 } |
3047 } | 3047 } |
OLD | NEW |