| 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 2384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3141 if (Elements.isUnresolved(redirectionTarget)) { | 3142 if (Elements.isUnresolved(redirectionTarget)) { |
| 3142 registry.registerThrowNoSuchMethod(); | 3143 registry.registerThrowNoSuchMethod(); |
| 3143 return; | 3144 return; |
| 3144 } else { | 3145 } else { |
| 3145 if (isConstConstructor && | 3146 if (isConstConstructor && |
| 3146 !redirectionTarget.isConst) { | 3147 !redirectionTarget.isConst) { |
| 3147 compiler.reportError(node, MessageKind.CONSTRUCTOR_IS_NOT_CONST); | 3148 compiler.reportError(node, MessageKind.CONSTRUCTOR_IS_NOT_CONST); |
| 3148 } | 3149 } |
| 3149 if (redirectionTarget == constructor) { | 3150 if (redirectionTarget == constructor) { |
| 3150 compiler.reportError(node, MessageKind.CYCLIC_REDIRECTING_FACTORY); | 3151 compiler.reportError(node, MessageKind.CYCLIC_REDIRECTING_FACTORY); |
| 3151 return; | |
| 3152 } | 3152 } |
| 3153 } | 3153 } |
| 3154 | 3154 |
| 3155 // Check that the target constructor is type compatible with the | 3155 // Check that the target constructor is type compatible with the |
| 3156 // redirecting constructor. | 3156 // redirecting constructor. |
| 3157 ClassElement targetClass = redirectionTarget.enclosingClass; | 3157 ClassElement targetClass = redirectionTarget.enclosingClass; |
| 3158 InterfaceType type = registry.getType(node); | 3158 InterfaceType type = registry.getType(node); |
| 3159 FunctionType targetType = redirectionTarget.computeType(compiler) | 3159 FunctionType targetType = redirectionTarget.computeType(compiler) |
| 3160 .subst(type.typeArguments, targetClass.typeVariables); | 3160 .subst(type.typeArguments, targetClass.typeVariables); |
| 3161 FunctionType constructorType = constructor.computeType(compiler); | 3161 FunctionType constructorType = constructor.computeType(compiler); |
| (...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4247 Selector callToMatch = new Selector.call("", element.library, 0); | 4247 Selector callToMatch = new Selector.call("", element.library, 0); |
| 4248 superConstructor.computeSignature(compiler); | 4248 superConstructor.computeSignature(compiler); |
| 4249 if (!callToMatch.applies(superConstructor, compiler.world)) { | 4249 if (!callToMatch.applies(superConstructor, compiler.world)) { |
| 4250 MessageKind kind = MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT; | 4250 MessageKind kind = MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT; |
| 4251 compiler.reportError(node, kind); | 4251 compiler.reportError(node, kind); |
| 4252 superMember = new ErroneousElementX(kind, {}, '', element); | 4252 superMember = new ErroneousElementX(kind, {}, '', element); |
| 4253 } | 4253 } |
| 4254 } | 4254 } |
| 4255 FunctionElement constructor = | 4255 FunctionElement constructor = |
| 4256 new SynthesizedConstructorElementX.forDefault(superMember, element); | 4256 new SynthesizedConstructorElementX.forDefault(superMember, element); |
| 4257 if (superMember.isErroneous) { |
| 4258 compiler.elementsWithCompileTimeErrors.add(constructor); |
| 4259 } |
| 4257 element.setDefaultConstructor(constructor, compiler); | 4260 element.setDefaultConstructor(constructor, compiler); |
| 4258 } | 4261 } |
| 4259 return element.computeType(compiler); | 4262 return element.computeType(compiler); |
| 4260 } | 4263 } |
| 4261 | 4264 |
| 4262 @override | 4265 @override |
| 4263 DartType visitEnum(Enum node) { | 4266 DartType visitEnum(Enum node) { |
| 4264 if (!compiler.enableEnums) { | 4267 if (!compiler.enableEnums) { |
| 4265 compiler.reportError(node, MessageKind.EXPERIMENTAL_ENUMS); | 4268 compiler.reportError(node, MessageKind.EXPERIMENTAL_ENUMS); |
| 4266 } | 4269 } |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5025 } | 5028 } |
| 5026 | 5029 |
| 5027 /// The result for the resolution of the `assert` method. | 5030 /// The result for the resolution of the `assert` method. |
| 5028 class AssertResult implements ResolutionResult { | 5031 class AssertResult implements ResolutionResult { |
| 5029 const AssertResult(); | 5032 const AssertResult(); |
| 5030 | 5033 |
| 5031 Element get element => null; | 5034 Element get element => null; |
| 5032 | 5035 |
| 5033 String toString() => 'AssertResult()'; | 5036 String toString() => 'AssertResult()'; |
| 5034 } | 5037 } |
| OLD | NEW |