OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 world_builder; | 5 part of world_builder; |
6 | 6 |
7 /// [ResolutionEnqueuerWorldBuilder] based on the [Element] model. | 7 /// [ResolutionEnqueuerWorldBuilder] based on the [Element] model. |
8 class ElementResolutionWorldBuilder extends ResolutionWorldBuilderBase { | 8 class ElementResolutionWorldBuilder extends ResolutionWorldBuilderBase { |
9 /// Used for testing the new more precise computation of instantiated types | 9 /// Used for testing the new more precise computation of instantiated types |
10 /// and classes. | 10 /// and classes. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 if (instance.isRedirection) { | 57 if (instance.isRedirection) { |
58 continue; | 58 continue; |
59 } | 59 } |
60 if (constructor == null || !constructor.isRedirectingFactory) { | 60 if (constructor == null || !constructor.isRedirectingFactory) { |
61 infoFor(cls) | 61 infoFor(cls) |
62 .addInstantiation(constructor, instance.type, instance.kind); | 62 .addInstantiation(constructor, instance.type, instance.kind); |
63 } else { | 63 } else { |
64 ConstructorElement target = constructor.effectiveTarget; | 64 ConstructorElement target = constructor.effectiveTarget; |
65 ResolutionInterfaceType targetType = | 65 ResolutionInterfaceType targetType = |
66 constructor.computeEffectiveTargetType(instance.type); | 66 constructor.computeEffectiveTargetType(instance.type); |
67 Instantiation kind = Instantiation.DIRECTLY_INSTANTIATED; | 67 ClassElement cls = target.enclosingClass; |
68 if (target.enclosingClass.isAbstract) { | 68 bool isNative = _nativeBasicData.isNativeClass(cls); |
69 // If target is a factory constructor on an abstract class. | 69 Instantiation kind; |
| 70 if (isNative) { |
| 71 kind = Instantiation.ABSTRACTLY_INSTANTIATED; |
| 72 } else if (cls.isAbstract) { |
70 kind = Instantiation.UNINSTANTIATED; | 73 kind = Instantiation.UNINSTANTIATED; |
| 74 } else { |
| 75 kind = Instantiation.DIRECTLY_INSTANTIATED; |
71 } | 76 } |
72 infoFor(targetType.element) | 77 infoFor(targetType.element) |
73 .addInstantiation(target, targetType, kind); | 78 .addInstantiation(target, targetType, kind); |
74 } | 79 } |
75 } | 80 } |
76 }); | 81 }); |
77 } | 82 } |
78 }); | 83 }); |
79 return instantiationMap; | 84 return instantiationMap; |
80 } | 85 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 classSets: _classSets); | 175 classSets: _classSets); |
171 } | 176 } |
172 | 177 |
173 @override | 178 @override |
174 void registerMixinUse( | 179 void registerMixinUse( |
175 MixinApplicationElement mixinApplication, ClassElement mixin) { | 180 MixinApplicationElement mixinApplication, ClassElement mixin) { |
176 assert(mixin.isDeclaration); | 181 assert(mixin.isDeclaration); |
177 super.registerMixinUse(mixinApplication, mixin); | 182 super.registerMixinUse(mixinApplication, mixin); |
178 } | 183 } |
179 } | 184 } |
OLD | NEW |