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

Unified Diff: pkg/compiler/lib/src/warnings.dart

Issue 709603003: Add compile-time errors for enums. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | « pkg/compiler/lib/src/resolution/members.dart ('k') | tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/warnings.dart
diff --git a/pkg/compiler/lib/src/warnings.dart b/pkg/compiler/lib/src/warnings.dart
index 5c3c1608d5cec5df6006bce67a3cef786941f7e1..1d72b64afcba9839f03dfcd148b2a58da2056bf5 100644
--- a/pkg/compiler/lib/src/warnings.dart
+++ b/pkg/compiler/lib/src/warnings.dart
@@ -797,6 +797,50 @@ typedef C = Object with String;
main() => new C();
"""]);
+ static const MessageKind CANNOT_EXTEND_ENUM = const MessageKind(
+ "Class '#{className}' can't extend the type '#{enumType}' because "
+ "it is declared by an enum.",
+ options: const ['--enable-enum'],
+ howToFix: "Try making '#{enumType}' a normal class or removing the "
+ "'extends' clause.",
+ examples: const ["""
+enum Enum {}
+class A extends Enum {}
+main() => new A();"""]);
+
+ static const MessageKind CANNOT_IMPLEMENT_ENUM = const MessageKind(
+ "Class '#{className}' can't implement the type '#{enumType}' "
+ "because it is declared by an enum.",
+ options: const ['--enable-enum'],
+ howToFix: "Try making '#{enumType}' a normal class or removing the "
+ "type from the 'implements' clause.",
+ examples: const ["""
+enum Enum {}
+class A implements Enum {}
+main() => new A();"""]);
+
+ static const MessageKind CANNOT_MIXIN_ENUM = const MessageKind(
+ "Class '#{className}' can't mixin the type '#{enumType}' because it "
+ "is declared by an enum.",
+ options: const ['--enable-enum'],
+ howToFix: "Try making '#{enumType}' a normal class or removing the "
+ "type from the 'with' clause.",
+ examples: const ["""
+enum Enum {}
+class A extends Object with Enum {}
+main() => new A();"""]);
+
+ static const MessageKind CANNOT_INSTANTIATE_ENUM = const MessageKind(
+ "Enum type '#{enumName}' cannot be instantiated.",
+ options: const ['--enable-enum'],
+ howToFix: "Try making '#{enumType}' a normal class or use an enum "
+ "constant.",
+ examples: const ["""
+enum Enum {}
+main() => new Enum(0, '');""", """
+enum Enum {}
+main() => const Enum(0, '');"""]);
+
static const MessageKind DUPLICATE_EXTENDS_IMPLEMENTS = const MessageKind(
"'#{type}' can not be both extended and implemented.");
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698