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

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

Issue 443923002: Add a compile time error for non-static const fields (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add language test. Created 6 years, 4 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 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 compiler.reportError( 1092 compiler.reportError(
1093 member, 1093 member,
1094 MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS, 1094 MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS,
1095 {'modifiers': mismatchedFlags}); 1095 {'modifiers': mismatchedFlags});
1096 } 1096 }
1097 if (member.modifiers.isConst) { 1097 if (member.modifiers.isConst) {
1098 constConstructors.add(member); 1098 constConstructors.add(member);
1099 } 1099 }
1100 } 1100 }
1101 if (member.isField) { 1101 if (member.isField) {
1102 if (!member.modifiers.isStatic && 1102 if (member.modifiers.isConst && !member.modifiers.isStatic) {
1103 !member.modifiers.isFinal) { 1103 compiler.reportError(
1104 member, MessageKind.ILLEGAL_CONST_FIELD_MODIFIER);
1105 }
1106 if (!member.modifiers.isStatic && !member.modifiers.isFinal) {
1104 nonFinalInstanceFields.add(member); 1107 nonFinalInstanceFields.add(member);
1105 } 1108 }
1106 } 1109 }
1107 checkAbstractField(member); 1110 checkAbstractField(member);
1108 checkUserDefinableOperator(member); 1111 checkUserDefinableOperator(member);
1109 }); 1112 });
1110 }); 1113 });
1111 if (!constConstructors.isEmpty && !nonFinalInstanceFields.isEmpty) { 1114 if (!constConstructors.isEmpty && !nonFinalInstanceFields.isEmpty) {
1112 Spannable span = constConstructors.length > 1 1115 Spannable span = constConstructors.length > 1
1113 ? cls : constConstructors[0]; 1116 ? cls : constConstructors[0];
(...skipping 3751 matching lines...) Expand 10 before | Expand all | Expand 10 after
4865 } 4868 }
4866 4869
4867 /// The result for the resolution of the `assert` method. 4870 /// The result for the resolution of the `assert` method.
4868 class AssertResult implements ResolutionResult { 4871 class AssertResult implements ResolutionResult {
4869 const AssertResult(); 4872 const AssertResult();
4870 4873
4871 Element get element => null; 4874 Element get element => null;
4872 4875
4873 String toString() => 'AssertResult()'; 4876 String toString() => 'AssertResult()';
4874 } 4877 }
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