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

Unified Diff: pkg/analyzer/lib/src/dart/error/hint_codes.dart

Issue 2775863004: Add error checking for the immutable annotation (issue 27750) (Closed)
Patch Set: Created 3 years, 9 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 | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
*
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698