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

Unified Diff: sdk/lib/_internal/compiler/implementation/warnings.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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/warnings.dart
diff --git a/sdk/lib/_internal/compiler/implementation/warnings.dart b/sdk/lib/_internal/compiler/implementation/warnings.dart
index 435b59499b3617b33bf19007f2ceeb9c08144342..653cdbed00721f745b5bc9650d2996c83efc2c54 100644
--- a/sdk/lib/_internal/compiler/implementation/warnings.dart
+++ b/sdk/lib/_internal/compiler/implementation/warnings.dart
@@ -991,6 +991,16 @@ main() => new C();"""]);
static const MessageKind ILLEGAL_FINAL_METHOD_MODIFIER = const MessageKind(
"Cannot have final modifier on method.");
+ static const MessageKind ILLEGAL_CONST_FIELD_MODIFIER = const MessageKind(
+ "Cannot have const modifier on non-static field.",
+ howToFix: "Try adding a static modifier, or removing the const modifier.",
+ examples: const ["""
+class C {
+ const int a = 1;
+}
+
+main() => new C();"""]);
+
static const MessageKind ILLEGAL_CONSTRUCTOR_MODIFIERS = const MessageKind(
"Illegal constructor modifiers: '#{modifiers}'.");
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | tests/language/const_instance_field_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698