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

Unified Diff: sdk/lib/_internal/compiler/implementation/warnings.dart

Issue 23533040: Check for non-final field in the face of const constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 59055aead79bb4fed3df30f75f7db6944ff659df..6f1f93841f7de292bf694bc4901cee5c6dae614e 100644
--- a/sdk/lib/_internal/compiler/implementation/warnings.dart
+++ b/sdk/lib/_internal/compiler/implementation/warnings.dart
@@ -272,6 +272,29 @@ class MessageKind {
static const MessageKind CONST_CALLS_NON_CONST = const MessageKind(
'Error: "const" constructor cannot call a non-const constructor.');
+ static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS =
+ const MessageKind(
+ "Error: Can't declare constructor 'const' on class #{className} "
+ "because the class contains non-final instance fields.",
+ howToFix: "Try making all fields final.",
+ examples: const ["""
+class C {
+ // 'a' must be declared final to allow for the const constructor.
+ var a;
+ const C(this.a);
+}
+
+main() => new C(0);"""]);
+
+ static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD =
+ const MessageKind('Info: This non-final field is blocking const '
karlklose 2013/09/05 12:43:42 'prevents using const constructors'?
Johnni Winther 2013/09/06 06:22:41 Done.
+ 'constructors.');
+
+ static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR =
karlklose 2013/09/05 12:43:42 And something similar here.
Johnni Winther 2013/09/06 06:22:41 Done.
+ const MessageKind('Info: This const constructor is blocked by '
+ 'non-final fields.');
+
+
static const MessageKind INITIALIZING_FORMAL_NOT_ALLOWED = const MessageKind(
'Error: Initializing formal parameter only allowed in generative '
'constructor.');

Powered by Google App Engine
This is Rietveld 408576698