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 library dart2js.resolution; | 5 library dart2js.resolution; |
6 | 6 |
7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
8 | 8 |
9 import '../common.dart'; | 9 import '../common.dart'; |
10 import '../common/names.dart' show Identifiers; | 10 import '../common/names.dart' show Identifiers; |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 reporter.reportErrorMessage( | 719 reporter.reportErrorMessage( |
720 member, MessageKind.ILLEGAL_MIXIN_CONSTRUCTOR); | 720 member, MessageKind.ILLEGAL_MIXIN_CONSTRUCTOR); |
721 } else { | 721 } else { |
722 // Get the resolution tree and check that the resolved member | 722 // Get the resolution tree and check that the resolved member |
723 // doesn't use 'super'. This is the part of the 'super' mixin | 723 // doesn't use 'super'. This is the part of the 'super' mixin |
724 // check that happens when a function is resolved before the | 724 // check that happens when a function is resolved before the |
725 // mixin application has been performed. | 725 // mixin application has been performed. |
726 // TODO(johnniwinther): Obtain the [TreeElements] for [member] | 726 // TODO(johnniwinther): Obtain the [TreeElements] for [member] |
727 // differently. | 727 // differently. |
728 if (compiler.enqueuer.resolution.hasBeenProcessed(member)) { | 728 if (compiler.enqueuer.resolution.hasBeenProcessed(member)) { |
729 checkMixinSuperUses( | 729 if (member.resolvedAst.kind == ResolvedAstKind.PARSED) { |
730 member.resolvedAst.elements, mixinApplication, mixin); | 730 checkMixinSuperUses( |
| 731 member.resolvedAst.elements, mixinApplication, mixin); |
| 732 } |
731 } | 733 } |
732 } | 734 } |
733 }); | 735 }); |
734 } | 736 } |
735 | 737 |
736 void checkMixinSuperUses(TreeElements resolutionTree, | 738 void checkMixinSuperUses(TreeElements elements, |
737 MixinApplicationElement mixinApplication, ClassElement mixin) { | 739 MixinApplicationElement mixinApplication, ClassElement mixin) { |
738 // TODO(johnniwinther): Avoid the use of [TreeElements] here. | 740 // TODO(johnniwinther): Avoid the use of [TreeElements] here. |
739 if (resolutionTree == null) return; | 741 Iterable<SourceSpan> superUses = elements.superUses; |
740 Iterable<SourceSpan> superUses = resolutionTree.superUses; | |
741 if (superUses.isEmpty) return; | 742 if (superUses.isEmpty) return; |
742 DiagnosticMessage error = reporter.createMessage(mixinApplication, | 743 DiagnosticMessage error = reporter.createMessage(mixinApplication, |
743 MessageKind.ILLEGAL_MIXIN_WITH_SUPER, {'className': mixin.name}); | 744 MessageKind.ILLEGAL_MIXIN_WITH_SUPER, {'className': mixin.name}); |
744 // Show the user the problematic uses of 'super' in the mixin. | 745 // Show the user the problematic uses of 'super' in the mixin. |
745 List<DiagnosticMessage> infos = <DiagnosticMessage>[]; | 746 List<DiagnosticMessage> infos = <DiagnosticMessage>[]; |
746 for (SourceSpan use in superUses) { | 747 for (SourceSpan use in superUses) { |
747 infos.add( | 748 infos.add( |
748 reporter.createMessage(use, MessageKind.ILLEGAL_MIXIN_SUPER_USE)); | 749 reporter.createMessage(use, MessageKind.ILLEGAL_MIXIN_SUPER_USE)); |
749 } | 750 } |
750 reporter.reportError(error, infos); | 751 reporter.reportError(error, infos); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 TreeElements get treeElements { | 1091 TreeElements get treeElements { |
1091 assert(invariant(this, _treeElements != null, | 1092 assert(invariant(this, _treeElements != null, |
1092 message: "TreeElements have not been computed for $this.")); | 1093 message: "TreeElements have not been computed for $this.")); |
1093 return _treeElements; | 1094 return _treeElements; |
1094 } | 1095 } |
1095 | 1096 |
1096 void reuseElement() { | 1097 void reuseElement() { |
1097 _treeElements = null; | 1098 _treeElements = null; |
1098 } | 1099 } |
1099 } | 1100 } |
OLD | NEW |