| 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 AnalyzableElement get analyzedElement; | 8 AnalyzableElement get analyzedElement; |
| 9 Iterable<Node> get superUses; | 9 Iterable<Node> get superUses; |
| 10 | 10 |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 assert(invariant(target, targetType != null, | 736 assert(invariant(target, targetType != null, |
| 737 message: 'Redirection target type has not been computed for ' | 737 message: 'Redirection target type has not been computed for ' |
| 738 '$target')); | 738 '$target')); |
| 739 target = target.internalEffectiveTarget; | 739 target = target.internalEffectiveTarget; |
| 740 break; | 740 break; |
| 741 } | 741 } |
| 742 | 742 |
| 743 Element nextTarget = target.immediateRedirectionTarget; | 743 Element nextTarget = target.immediateRedirectionTarget; |
| 744 if (seen.contains(nextTarget)) { | 744 if (seen.contains(nextTarget)) { |
| 745 error(node, MessageKind.CYCLIC_REDIRECTING_FACTORY); | 745 error(node, MessageKind.CYCLIC_REDIRECTING_FACTORY); |
| 746 return; | 746 targetType = target.enclosingClass.thisType; |
| 747 break; |
| 747 } | 748 } |
| 748 seen.add(target); | 749 seen.add(target); |
| 749 target = nextTarget; | 750 target = nextTarget; |
| 750 } | 751 } |
| 751 | 752 |
| 752 if (targetType == null) { | 753 if (targetType == null) { |
| 753 assert(!target.isRedirectingFactory); | 754 assert(!target.isRedirectingFactory); |
| 754 targetType = target.enclosingClass.thisType; | 755 targetType = target.enclosingClass.thisType; |
| 755 } | 756 } |
| 756 | 757 |
| (...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3143 if (Elements.isUnresolved(redirectionTarget)) { | 3144 if (Elements.isUnresolved(redirectionTarget)) { |
| 3144 registry.registerThrowNoSuchMethod(); | 3145 registry.registerThrowNoSuchMethod(); |
| 3145 return; | 3146 return; |
| 3146 } else { | 3147 } else { |
| 3147 if (isConstConstructor && | 3148 if (isConstConstructor && |
| 3148 !redirectionTarget.isConst) { | 3149 !redirectionTarget.isConst) { |
| 3149 compiler.reportError(node, MessageKind.CONSTRUCTOR_IS_NOT_CONST); | 3150 compiler.reportError(node, MessageKind.CONSTRUCTOR_IS_NOT_CONST); |
| 3150 } | 3151 } |
| 3151 if (redirectionTarget == constructor) { | 3152 if (redirectionTarget == constructor) { |
| 3152 compiler.reportError(node, MessageKind.CYCLIC_REDIRECTING_FACTORY); | 3153 compiler.reportError(node, MessageKind.CYCLIC_REDIRECTING_FACTORY); |
| 3153 return; | |
| 3154 } | 3154 } |
| 3155 } | 3155 } |
| 3156 | 3156 |
| 3157 // Check that the target constructor is type compatible with the | 3157 // Check that the target constructor is type compatible with the |
| 3158 // redirecting constructor. | 3158 // redirecting constructor. |
| 3159 ClassElement targetClass = redirectionTarget.enclosingClass; | 3159 ClassElement targetClass = redirectionTarget.enclosingClass; |
| 3160 InterfaceType type = registry.getType(node); | 3160 InterfaceType type = registry.getType(node); |
| 3161 FunctionType targetType = redirectionTarget.computeType(compiler) | 3161 FunctionType targetType = redirectionTarget.computeType(compiler) |
| 3162 .subst(type.typeArguments, targetClass.typeVariables); | 3162 .subst(type.typeArguments, targetClass.typeVariables); |
| 3163 FunctionType constructorType = constructor.computeType(compiler); | 3163 FunctionType constructorType = constructor.computeType(compiler); |
| (...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4250 Selector callToMatch = new Selector.call("", element.library, 0); | 4250 Selector callToMatch = new Selector.call("", element.library, 0); |
| 4251 superConstructor.computeSignature(compiler); | 4251 superConstructor.computeSignature(compiler); |
| 4252 if (!callToMatch.applies(superConstructor, compiler.world)) { | 4252 if (!callToMatch.applies(superConstructor, compiler.world)) { |
| 4253 MessageKind kind = MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT; | 4253 MessageKind kind = MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT; |
| 4254 compiler.reportError(node, kind); | 4254 compiler.reportError(node, kind); |
| 4255 superMember = new ErroneousElementX(kind, {}, '', element); | 4255 superMember = new ErroneousElementX(kind, {}, '', element); |
| 4256 } | 4256 } |
| 4257 } | 4257 } |
| 4258 FunctionElement constructor = | 4258 FunctionElement constructor = |
| 4259 new SynthesizedConstructorElementX.forDefault(superMember, element); | 4259 new SynthesizedConstructorElementX.forDefault(superMember, element); |
| 4260 if (superMember.isErroneous) { |
| 4261 compiler.elementsWithCompileTimeErrors.add(constructor); |
| 4262 } |
| 4260 element.setDefaultConstructor(constructor, compiler); | 4263 element.setDefaultConstructor(constructor, compiler); |
| 4261 } | 4264 } |
| 4262 return element.computeType(compiler); | 4265 return element.computeType(compiler); |
| 4263 } | 4266 } |
| 4264 | 4267 |
| 4265 @override | 4268 @override |
| 4266 DartType visitEnum(Enum node) { | 4269 DartType visitEnum(Enum node) { |
| 4267 if (!compiler.enableEnums) { | 4270 if (!compiler.enableEnums) { |
| 4268 compiler.reportError(node, MessageKind.EXPERIMENTAL_ENUMS); | 4271 compiler.reportError(node, MessageKind.EXPERIMENTAL_ENUMS); |
| 4269 } | 4272 } |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5036 } | 5039 } |
| 5037 | 5040 |
| 5038 /// The result for the resolution of the `assert` method. | 5041 /// The result for the resolution of the `assert` method. |
| 5039 class AssertResult implements ResolutionResult { | 5042 class AssertResult implements ResolutionResult { |
| 5040 const AssertResult(); | 5043 const AssertResult(); |
| 5041 | 5044 |
| 5042 Element get element => null; | 5045 Element get element => null; |
| 5043 | 5046 |
| 5044 String toString() => 'AssertResult()'; | 5047 String toString() => 'AssertResult()'; |
| 5045 } | 5048 } |
| OLD | NEW |