| 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 '../common/resolution.dart' show Feature; | 8 import '../common/resolution.dart' show Feature; |
| 9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
| 10 import '../constants/constructors.dart' | 10 import '../constants/constructors.dart' |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 ArgumentsResult argumentsResult = visitor.inStaticContext(() { | 159 ArgumentsResult argumentsResult = visitor.inStaticContext(() { |
| 160 // TODO(johnniwinther): Remove this when [SendStructure] is used directly. | 160 // TODO(johnniwinther): Remove this when [SendStructure] is used directly. |
| 161 visitor.resolveSelector(node, null); | 161 visitor.resolveSelector(node, null); |
| 162 return visitor.resolveArguments(node.argumentsNode); | 162 return visitor.resolveArguments(node.argumentsNode); |
| 163 }, inConstantInitializer: isConst); | 163 }, inConstantInitializer: isConst); |
| 164 | 164 |
| 165 bool isSuperCall = Initializers.isSuperConstructorCall(node); | 165 bool isSuperCall = Initializers.isSuperConstructorCall(node); |
| 166 InterfaceType targetType = | 166 InterfaceType targetType = |
| 167 getSuperOrThisLookupTarget(node, isSuperCall: isSuperCall); | 167 getSuperOrThisLookupTarget(node, isSuperCall: isSuperCall); |
| 168 ClassElement lookupTarget = targetType.element; | 168 ClassElement lookupTarget = targetType.element; |
| 169 if (constructor.library == lookupTarget.library) { |
| 170 // This allows a class in a patch library to find injected constructors. |
| 171 lookupTarget = lookupTarget.implementation; |
| 172 } |
| 169 String constructorName = | 173 String constructorName = |
| 170 visitor.getRedirectingThisOrSuperConstructorName(node).text; | 174 visitor.getRedirectingThisOrSuperConstructorName(node).text; |
| 171 ConstructorElement foundConstructor = | 175 ConstructorElement foundConstructor = |
| 172 findConstructor(constructor.library, lookupTarget, constructorName); | 176 findConstructor(constructor.library, lookupTarget, constructorName); |
| 173 | 177 |
| 174 final bool isImplicitSuperCall = false; | 178 final bool isImplicitSuperCall = false; |
| 175 final String className = lookupTarget.name; | 179 final String className = lookupTarget.name; |
| 176 CallStructure callStructure = argumentsResult.callStructure; | 180 CallStructure callStructure = argumentsResult.callStructure; |
| 177 ConstructorElement calledConstructor = verifyThatConstructorMatchesCall( | 181 ConstructorElement calledConstructor = verifyThatConstructorMatchesCall( |
| 178 node, foundConstructor, callStructure, className, | 182 node, foundConstructor, callStructure, className, |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 // constructors. | 854 // constructors. |
| 851 return null; | 855 return null; |
| 852 } | 856 } |
| 853 // TODO(johnniwinther): Use [Name] for lookup. | 857 // TODO(johnniwinther): Use [Name] for lookup. |
| 854 ConstructorElement constructor = cls.lookupConstructor(constructorName); | 858 ConstructorElement constructor = cls.lookupConstructor(constructorName); |
| 855 if (constructor != null) { | 859 if (constructor != null) { |
| 856 constructor = constructor.declaration; | 860 constructor = constructor.declaration; |
| 857 } | 861 } |
| 858 return constructor; | 862 return constructor; |
| 859 } | 863 } |
| OLD | NEW |