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

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: Updated cf. comments. 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 1694daa7e58bae9c51aab92e5eac028d31e8463c..c108cf83ab36a965fee6166061a65fefb4c3a005 100644
--- a/sdk/lib/_internal/compiler/implementation/warnings.dart
+++ b/sdk/lib/_internal/compiler/implementation/warnings.dart
@@ -282,6 +282,29 @@ main() => new C();"""]);
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 prevents using const '
+ 'constructors.');
+
+ static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR =
+ const MessageKind('Info: This const constructor is not allowed due to '
+ 'non-final fields.');
+
+
static const MessageKind INITIALIZING_FORMAL_NOT_ALLOWED = const MessageKind(
'Error: Initializing formal parameter only allowed in generative '
'constructor.');
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | sdk/lib/_internal/lib/foreign_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698