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 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 reporter.reportError(error, infos); | 796 reporter.reportError(error, infos); |
797 } | 797 } |
798 | 798 |
799 void checkClassMembers(ClassElement cls) { | 799 void checkClassMembers(ClassElement cls) { |
800 assert(invariant(cls, cls.isDeclaration)); | 800 assert(invariant(cls, cls.isDeclaration)); |
801 if (cls.isObject) return; | 801 if (cls.isObject) return; |
802 // TODO(johnniwinther): Should this be done on the implementation element as | 802 // TODO(johnniwinther): Should this be done on the implementation element as |
803 // well? | 803 // well? |
804 List<Element> constConstructors = <Element>[]; | 804 List<Element> constConstructors = <Element>[]; |
805 List<Element> nonFinalInstanceFields = <Element>[]; | 805 List<Element> nonFinalInstanceFields = <Element>[]; |
806 cls.forEachMember((holder, member) { | 806 cls.forEachMember((holder, dynamic member) { |
807 reporter.withCurrentElement(member, () { | 807 reporter.withCurrentElement(member, () { |
808 // Perform various checks as side effect of "computing" the type. | 808 // Perform various checks as side effect of "computing" the type. |
809 member.computeType(resolution); | 809 member.computeType(resolution); |
810 | 810 |
811 // Check modifiers. | 811 // Check modifiers. |
| 812 // ignore: UNDEFINED_GETTER |
812 if (member.isFunction && member.modifiers.isFinal) { | 813 if (member.isFunction && member.modifiers.isFinal) { |
813 reporter.reportErrorMessage( | 814 reporter.reportErrorMessage( |
814 member, MessageKind.ILLEGAL_FINAL_METHOD_MODIFIER); | 815 member, MessageKind.ILLEGAL_FINAL_METHOD_MODIFIER); |
815 } | 816 } |
816 if (member.isConstructor) { | 817 if (member.isConstructor) { |
| 818 // ignore: UNDEFINED_GETTER |
817 final mismatchedFlagsBits = member.modifiers.flags & | 819 final mismatchedFlagsBits = member.modifiers.flags & |
818 (Modifiers.FLAG_STATIC | Modifiers.FLAG_ABSTRACT); | 820 (Modifiers.FLAG_STATIC | Modifiers.FLAG_ABSTRACT); |
819 if (mismatchedFlagsBits != 0) { | 821 if (mismatchedFlagsBits != 0) { |
820 final mismatchedFlags = | 822 final mismatchedFlags = |
821 new Modifiers.withFlags(null, mismatchedFlagsBits); | 823 new Modifiers.withFlags(null, mismatchedFlagsBits); |
822 reporter.reportErrorMessage( | 824 reporter.reportErrorMessage( |
823 member, | 825 member, |
824 MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS, | 826 MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS, |
825 {'modifiers': mismatchedFlags}); | 827 {'modifiers': mismatchedFlags}); |
826 } | 828 } |
| 829 // ignore: UNDEFINED_GETTER |
827 if (member.modifiers.isConst) { | 830 if (member.modifiers.isConst) { |
828 constConstructors.add(member); | 831 constConstructors.add(member); |
829 } | 832 } |
830 } | 833 } |
831 if (member.isField) { | 834 if (member.isField) { |
| 835 // ignore: UNDEFINED_GETTER |
832 if (member.modifiers.isConst && !member.modifiers.isStatic) { | 836 if (member.modifiers.isConst && !member.modifiers.isStatic) { |
833 reporter.reportErrorMessage( | 837 reporter.reportErrorMessage( |
834 member, MessageKind.ILLEGAL_CONST_FIELD_MODIFIER); | 838 member, MessageKind.ILLEGAL_CONST_FIELD_MODIFIER); |
835 } | 839 } |
| 840 // ignore: UNDEFINED_GETTER |
836 if (!member.modifiers.isStatic && !member.modifiers.isFinal) { | 841 if (!member.modifiers.isStatic && !member.modifiers.isFinal) { |
837 nonFinalInstanceFields.add(member); | 842 nonFinalInstanceFields.add(member); |
838 } | 843 } |
839 } | 844 } |
840 checkAbstractField(member); | 845 checkAbstractField(member); |
841 checkUserDefinableOperator(member); | 846 checkUserDefinableOperator(member); |
842 }); | 847 }); |
843 }); | 848 }); |
844 if (!constConstructors.isEmpty && !nonFinalInstanceFields.isEmpty) { | 849 if (!constConstructors.isEmpty && !nonFinalInstanceFields.isEmpty) { |
845 Spannable span = | 850 Spannable span = |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 TreeElements get treeElements { | 1144 TreeElements get treeElements { |
1140 assert(invariant(this, _treeElements != null, | 1145 assert(invariant(this, _treeElements != null, |
1141 message: "TreeElements have not been computed for $this.")); | 1146 message: "TreeElements have not been computed for $this.")); |
1142 return _treeElements; | 1147 return _treeElements; |
1143 } | 1148 } |
1144 | 1149 |
1145 void reuseElement() { | 1150 void reuseElement() { |
1146 _treeElements = null; | 1151 _treeElements = null; |
1147 } | 1152 } |
1148 } | 1153 } |
OLD | NEW |