| 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 get currentElement; | 8 Element get currentElement; |
| 9 Set<Node> get superUses; | 9 Set<Node> get superUses; |
| 10 | 10 |
| (...skipping 3994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4005 return finishConstructorReference(e, node.send.selector, node); | 4005 return finishConstructorReference(e, node.send.selector, node); |
| 4006 } | 4006 } |
| 4007 | 4007 |
| 4008 /// Finishes resolution of a constructor reference and records the | 4008 /// Finishes resolution of a constructor reference and records the |
| 4009 /// type of the constructed instance on [expression]. | 4009 /// type of the constructed instance on [expression]. |
| 4010 FunctionElement finishConstructorReference(Element e, | 4010 FunctionElement finishConstructorReference(Element e, |
| 4011 Node diagnosticNode, | 4011 Node diagnosticNode, |
| 4012 Node expression) { | 4012 Node expression) { |
| 4013 // Find the unnamed constructor if the reference resolved to a | 4013 // Find the unnamed constructor if the reference resolved to a |
| 4014 // class. | 4014 // class. |
| 4015 if (!Elements.isUnresolved(e) && e.isClass()) { | 4015 if (!Elements.isUnresolved(e) && !e.isConstructor()) { |
| 4016 ClassElement cls = e; | 4016 if (e.isClass()) { |
| 4017 cls.ensureResolved(compiler); | 4017 ClassElement cls = e; |
| 4018 // The unnamed constructor may not exist, so [e] may become unresolved. | 4018 cls.ensureResolved(compiler); |
| 4019 e = lookupConstructor(cls, diagnosticNode, const SourceString('')); | 4019 // The unnamed constructor may not exist, so [e] may become unresolved. |
| 4020 e = lookupConstructor(cls, diagnosticNode, const SourceString('')); |
| 4021 } else { |
| 4022 error(diagnosticNode, |
| 4023 MessageKind.NOT_A_TYPE.error, |
| 4024 {'node': diagnosticNode}); |
| 4025 } |
| 4020 } | 4026 } |
| 4021 if (type == null) { | 4027 if (type == null) { |
| 4022 if (Elements.isUnresolved(e)) { | 4028 if (Elements.isUnresolved(e)) { |
| 4023 type = compiler.types.dynamicType; | 4029 type = compiler.types.dynamicType; |
| 4024 } else { | 4030 } else { |
| 4025 type = e.getEnclosingClass().computeType(compiler).asRaw(); | 4031 type = e.getEnclosingClass().computeType(compiler).asRaw(); |
| 4026 } | 4032 } |
| 4027 } | 4033 } |
| 4028 resolver.mapping.setType(expression, type); | 4034 resolver.mapping.setType(expression, type); |
| 4029 return e; | 4035 return e; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4087 return e; | 4093 return e; |
| 4088 } | 4094 } |
| 4089 | 4095 |
| 4090 /// Assumed to be called by [resolveRedirectingFactory]. | 4096 /// Assumed to be called by [resolveRedirectingFactory]. |
| 4091 Element visitReturn(Return node) { | 4097 Element visitReturn(Return node) { |
| 4092 Node expression = node.expression; | 4098 Node expression = node.expression; |
| 4093 return finishConstructorReference(visit(expression), | 4099 return finishConstructorReference(visit(expression), |
| 4094 expression, expression); | 4100 expression, expression); |
| 4095 } | 4101 } |
| 4096 } | 4102 } |
| OLD | NEW |