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

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

Issue 23503035: Emit a compile-time error on const constructors with a body. (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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1694daa7e58bae9c51aab92e5eac028d31e8463c 100644
--- a/sdk/lib/_internal/compiler/implementation/warnings.dart
+++ b/sdk/lib/_internal/compiler/implementation/warnings.dart
@@ -241,7 +241,17 @@ class MessageKind {
'Error: Cyclic constructor redirection.');
static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_BODY = const MessageKind(
- 'Error: Redirecting constructor cannot have a body.');
+ "Error: Redirecting constructor can't have a body.");
+
+ static const MessageKind CONST_CONSTRUCTOR_HAS_BODY = const MessageKind(
+ "Error: Const constructor or factory can't have a body.",
+ howToFix: "Remove the 'const' keyword or the body",
+ examples: const ["""
+class C {
+ const C() {}
+}
+
+main() => new C();"""]);
static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER =
const MessageKind(
@@ -501,7 +511,7 @@ class MessageKind {
'Error: Cannot have return type for constructor.');
static const MessageKind CANNOT_RETURN_FROM_CONSTRUCTOR = const MessageKind(
- "Error: Cannot return a value from a constructor.",
+ "Error: Constructors can't return values.",
howToFix: "Remove the return statement or use a factory constructor.",
examples: const ["""
class C {
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698