Index: pkg/analyzer/lib/src/dart/error/hint_codes.dart |
diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.dart |
index 6a0c291a46f813d509236922914483bc811b330f..4cfce64ded54abeeab19782e76185be3fc370012 100644 |
--- a/pkg/analyzer/lib/src/dart/error/hint_codes.dart |
+++ b/pkg/analyzer/lib/src/dart/error/hint_codes.dart |
@@ -216,6 +216,14 @@ class HintCode extends ErrorCode { |
"Factory method '{0}' doesn't return a newly allocated object."); |
/** |
+ * This hint is generated anywhere an @immutable annotation is associated with |
+ * anything other than a class. |
+ */ |
+ static const HintCode INVALID_IMMUTABLE_ANNOTATION = const HintCode( |
+ 'INVALID_IMMUTABLE_ANNOTATION', |
+ "Only classes can be annotated as being immutable."); |
+ |
+ /** |
* Generic Method DEP: number of type parameters must match. |
* <https://github.com/leafpetersen/dep-generic-methods/blob/master/proposal.md#function-subtyping> |
* |
@@ -345,6 +353,15 @@ class HintCode extends ErrorCode { |
"Try adding a return statement, or changing the return type to 'void'."); |
/** |
+ * Generate a hint for classes that inherit from classes annotated with |
+ * `@immutable` but that are not immutable. |
+ */ |
+ static const HintCode MUST_BE_IMMUTABLE = const HintCode( |
+ 'MUST_BE_IMMUTABLE', |
+ "This class inherits from a class marked as @immutable, " |
+ "and therefore should be immutable (all fields must be final)."); |
+ |
+ /** |
* Generate a hint for methods that override methods annotated `@mustCallSuper` |
* that do not invoke the overridden super method. |
* |