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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 element.asyncMarker.isYielding) { | 523 element.asyncMarker.isYielding) { |
524 compiler.reportError(asyncModifier, | 524 compiler.reportError(asyncModifier, |
525 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY, | 525 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY, |
526 {'modifier': element.asyncMarker}); | 526 {'modifier': element.asyncMarker}); |
527 } | 527 } |
528 } | 528 } |
529 registry.registerAsyncMarker(element); | 529 registry.registerAsyncMarker(element); |
530 } | 530 } |
531 } | 531 } |
532 | 532 |
| 533 bool _isNativeClassOrExtendsNativeClass(ClassElement classElement) { |
| 534 assert(classElement != null); |
| 535 while (classElement != null) { |
| 536 if (classElement.isNative) return true; |
| 537 classElement = classElement.superclass; |
| 538 } |
| 539 return false; |
| 540 } |
| 541 |
533 TreeElements resolveMethodElementImplementation( | 542 TreeElements resolveMethodElementImplementation( |
534 FunctionElement element, FunctionExpression tree) { | 543 FunctionElement element, FunctionExpression tree) { |
535 return compiler.withCurrentElement(element, () { | 544 return compiler.withCurrentElement(element, () { |
536 if (element.isExternal && tree.hasBody()) { | 545 if (element.isExternal && tree.hasBody()) { |
537 compiler.reportError(element, | 546 error(element, |
538 MessageKind.EXTERNAL_WITH_BODY, | 547 MessageKind.EXTERNAL_WITH_BODY, |
539 {'functionName': element.name}); | 548 {'functionName': element.name}); |
540 } | 549 } |
541 if (element.isConstructor) { | 550 if (element.isConstructor) { |
542 if (tree.returnType != null) { | 551 if (tree.returnType != null) { |
543 compiler.reportError(tree, MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE); | 552 error(tree, MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE); |
544 } | 553 } |
545 if (element.isConst && | 554 if (element.isConst && |
546 tree.hasBody() && | 555 tree.hasBody() && |
547 !tree.isRedirectingFactory) { | 556 !tree.isRedirectingFactory) { |
548 compiler.reportError(tree, MessageKind.CONST_CONSTRUCTOR_HAS_BODY); | 557 error(tree, MessageKind.CONST_CONSTRUCTOR_HAS_BODY); |
549 } | 558 } |
550 } | 559 } |
551 | 560 |
552 ResolverVisitor visitor = visitorFor(element); | 561 ResolverVisitor visitor = visitorFor(element); |
553 ResolutionRegistry registry = visitor.registry; | 562 ResolutionRegistry registry = visitor.registry; |
554 registry.defineFunction(tree, element); | 563 registry.defineFunction(tree, element); |
555 visitor.setupFunction(tree, element); | 564 visitor.setupFunction(tree, element); |
556 processAsyncMarker(compiler, element, registry); | 565 processAsyncMarker(compiler, element, registry); |
557 | 566 |
558 if (element.isGenerativeConstructor) { | 567 if (element.isGenerativeConstructor) { |
(...skipping 24 matching lines...) Expand all Loading... |
583 ClassElement enclosingClass = element.enclosingClass; | 592 ClassElement enclosingClass = element.enclosingClass; |
584 if (enclosingClass != null) { | 593 if (enclosingClass != null) { |
585 // TODO(johnniwinther): Find another way to obtain mixin uses. | 594 // TODO(johnniwinther): Find another way to obtain mixin uses. |
586 Iterable<MixinApplicationElement> mixinUses = | 595 Iterable<MixinApplicationElement> mixinUses = |
587 compiler.world.allMixinUsesOf(enclosingClass); | 596 compiler.world.allMixinUsesOf(enclosingClass); |
588 ClassElement mixin = enclosingClass; | 597 ClassElement mixin = enclosingClass; |
589 for (MixinApplicationElement mixinApplication in mixinUses) { | 598 for (MixinApplicationElement mixinApplication in mixinUses) { |
590 checkMixinSuperUses(resolutionTree, mixinApplication, mixin); | 599 checkMixinSuperUses(resolutionTree, mixinApplication, mixin); |
591 } | 600 } |
592 } | 601 } |
| 602 |
| 603 // TODO(9631): support noSuchMethod on native classes. |
| 604 if (Elements.isInstanceMethod(element) && |
| 605 element.name == Compiler.NO_SUCH_METHOD && |
| 606 _isNativeClassOrExtendsNativeClass(enclosingClass)) { |
| 607 error(tree, MessageKind.NO_SUCH_METHOD_IN_NATIVE); |
| 608 } |
| 609 |
593 return resolutionTree; | 610 return resolutionTree; |
594 }); | 611 }); |
595 | 612 |
596 } | 613 } |
597 | 614 |
598 TreeElements resolveMethodElement(FunctionElementX element) { | 615 TreeElements resolveMethodElement(FunctionElementX element) { |
599 assert(invariant(element, element.isDeclaration)); | 616 assert(invariant(element, element.isDeclaration)); |
600 return compiler.withCurrentElement(element, () { | 617 return compiler.withCurrentElement(element, () { |
601 if (compiler.enqueuer.resolution.hasBeenResolved(element)) { | 618 if (compiler.enqueuer.resolution.hasBeenResolved(element)) { |
602 // TODO(karlklose): Remove the check for [isConstructor]. [elememts] | 619 // TODO(karlklose): Remove the check for [isConstructor]. [elememts] |
(...skipping 4433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5036 } | 5053 } |
5037 | 5054 |
5038 /// The result for the resolution of the `assert` method. | 5055 /// The result for the resolution of the `assert` method. |
5039 class AssertResult implements ResolutionResult { | 5056 class AssertResult implements ResolutionResult { |
5040 const AssertResult(); | 5057 const AssertResult(); |
5041 | 5058 |
5042 Element get element => null; | 5059 Element get element => null; |
5043 | 5060 |
5044 String toString() => 'AssertResult()'; | 5061 String toString() => 'AssertResult()'; |
5045 } | 5062 } |
OLD | NEW |