OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.resolution.constructors; | 5 library dart2js.resolution.constructors; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../compiler.dart' show | 8 import '../compiler.dart' show |
9 Compiler; | 9 Compiler; |
10 import '../constants/constructors.dart' show | 10 import '../constants/constructors.dart' show |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } else { | 139 } else { |
140 isValidAsConstant = false; | 140 isValidAsConstant = false; |
141 } | 141 } |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 InterfaceType getSuperOrThisLookupTarget(Node diagnosticNode, | 145 InterfaceType getSuperOrThisLookupTarget(Node diagnosticNode, |
146 {bool isSuperCall}) { | 146 {bool isSuperCall}) { |
147 if (isSuperCall) { | 147 if (isSuperCall) { |
148 // Calculate correct lookup target and constructor name. | 148 // Calculate correct lookup target and constructor name. |
149 if (identical(constructor.enclosingClass, visitor.compiler.objectClass)) { | 149 if (constructor.enclosingClass.isObject) { |
150 reporter.reportErrorMessage( | 150 reporter.reportErrorMessage( |
151 diagnosticNode, MessageKind.SUPER_INITIALIZER_IN_OBJECT); | 151 diagnosticNode, MessageKind.SUPER_INITIALIZER_IN_OBJECT); |
152 isValidAsConstant = false; | 152 isValidAsConstant = false; |
153 } else { | 153 } else { |
154 return constructor.enclosingClass.supertype; | 154 return constructor.enclosingClass.supertype; |
155 } | 155 } |
156 } | 156 } |
157 return constructor.enclosingClass.thisType; | 157 return constructor.enclosingClass.thisType; |
158 } | 158 } |
159 | 159 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 isValidAsConstant = false; | 203 isValidAsConstant = false; |
204 } | 204 } |
205 } | 205 } |
206 return new ResolutionResult.forElement(calledConstructor); | 206 return new ResolutionResult.forElement(calledConstructor); |
207 } | 207 } |
208 | 208 |
209 ConstructedConstantExpression resolveImplicitSuperConstructorSend() { | 209 ConstructedConstantExpression resolveImplicitSuperConstructorSend() { |
210 // If the class has a super resolve the implicit super call. | 210 // If the class has a super resolve the implicit super call. |
211 ClassElement classElement = constructor.enclosingClass; | 211 ClassElement classElement = constructor.enclosingClass; |
212 ClassElement superClass = classElement.superclass; | 212 ClassElement superClass = classElement.superclass; |
213 if (classElement != visitor.compiler.objectClass) { | 213 if (!classElement.isObject) { |
214 assert(superClass != null); | 214 assert(superClass != null); |
215 assert(superClass.isResolved); | 215 assert(superClass.isResolved); |
216 | 216 |
217 InterfaceType targetType = | 217 InterfaceType targetType = |
218 getSuperOrThisLookupTarget(functionNode, isSuperCall: true); | 218 getSuperOrThisLookupTarget(functionNode, isSuperCall: true); |
219 ClassElement lookupTarget = targetType.element; | 219 ClassElement lookupTarget = targetType.element; |
220 Selector constructorSelector = new Selector.callDefaultConstructor(); | 220 Selector constructorSelector = new Selector.callDefaultConstructor(); |
221 ConstructorElement calledConstructor = findConstructor( | 221 ConstructorElement calledConstructor = findConstructor( |
222 constructor.library, | 222 constructor.library, |
223 lookupTarget, | 223 lookupTarget, |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 // constructors. | 753 // constructors. |
754 return null; | 754 return null; |
755 } | 755 } |
756 // TODO(johnniwinther): Use [Name] for lookup. | 756 // TODO(johnniwinther): Use [Name] for lookup. |
757 ConstructorElement constructor = cls.lookupConstructor(constructorName); | 757 ConstructorElement constructor = cls.lookupConstructor(constructorName); |
758 if (constructor != null) { | 758 if (constructor != null) { |
759 constructor = constructor.declaration; | 759 constructor = constructor.declaration; |
760 } | 760 } |
761 return constructor; | 761 return constructor; |
762 } | 762 } |
OLD | NEW |