Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 339583004: Add a compile time error for non-static const fields (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressing Comment Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Element get currentElement; 8 Element get currentElement;
9 Setlet<Node> get superUses; 9 Setlet<Node> get superUses;
10 10
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 compiler.reportError( 971 compiler.reportError(
972 member, 972 member,
973 MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS, 973 MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS,
974 {'modifiers': mismatchedFlags}); 974 {'modifiers': mismatchedFlags});
975 } 975 }
976 if (member.modifiers.isConst) { 976 if (member.modifiers.isConst) {
977 constConstructors.add(member); 977 constConstructors.add(member);
978 } 978 }
979 } 979 }
980 if (member.isField) { 980 if (member.isField) {
981 if (!member.modifiers.isStatic && 981 if (member.modifiers.isConst && !member.modifiers.isStatic) {
982 !member.modifiers.isFinal) { 982 compiler.reportError(
983 member, MessageKind.ILLEGAL_CONST_FIELD_MODIFIER);
984 }
985 if (!member.modifiers.isStatic && !member.modifiers.isFinal) {
983 nonFinalInstanceFields.add(member); 986 nonFinalInstanceFields.add(member);
984 } 987 }
985 } 988 }
986 checkAbstractField(member); 989 checkAbstractField(member);
987 checkUserDefinableOperator(member); 990 checkUserDefinableOperator(member);
988 }); 991 });
989 }); 992 });
990 if (!constConstructors.isEmpty && !nonFinalInstanceFields.isEmpty) { 993 if (!constConstructors.isEmpty && !nonFinalInstanceFields.isEmpty) {
991 Spannable span = constConstructors.length > 1 994 Spannable span = constConstructors.length > 1
992 ? cls : constConstructors[0]; 995 ? cls : constConstructors[0];
(...skipping 3699 matching lines...) Expand 10 before | Expand all | Expand 10 after
4692 TreeElements _treeElements; 4695 TreeElements _treeElements;
4693 4696
4694 bool get hasTreeElements => _treeElements != null; 4697 bool get hasTreeElements => _treeElements != null;
4695 4698
4696 TreeElements get treeElements { 4699 TreeElements get treeElements {
4697 assert(invariant(this, _treeElements !=null, 4700 assert(invariant(this, _treeElements !=null,
4698 message: "TreeElements have not been computed for $this.")); 4701 message: "TreeElements have not been computed for $this."));
4699 return _treeElements; 4702 return _treeElements;
4700 } 4703 }
4701 } 4704 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698