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

Unified Diff: pkg/analyzer/lib/src/dart/element/element.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/error/error.dart ('k') | pkg/analyzer/lib/src/dart/error/hint_codes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 0636e28a842d47da4bfd8b3cd183b25a2d2b20da..cb194b0261d713bb450c24e07da64898b70516fb 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -2465,6 +2465,12 @@ class ElementAnnotationImpl implements ElementAnnotation {
static String _FACTORY_VARIABLE_NAME = "factory";
/**
+ * The name of the top-level variable used to mark a class and its subclasses
+ * as being immutable.
+ */
+ static String _IMMUTABLE_VARIABLE_NAME = "immutable";
+
+ /**
* The name of the class used to JS annotate an element.
*/
static String _JS_CLASS_NAME = "JS";
@@ -2584,6 +2590,12 @@ class ElementAnnotationImpl implements ElementAnnotation {
element.library?.name == _META_LIB_NAME;
@override
+ bool get isImmutable =>
+ element is PropertyAccessorElement &&
+ element.name == _IMMUTABLE_VARIABLE_NAME &&
+ element.library?.name == _META_LIB_NAME;
+
+ @override
bool get isJS =>
element is ConstructorElement &&
element.enclosingElement.name == _JS_CLASS_NAME &&
« no previous file with comments | « pkg/analyzer/lib/error/error.dart ('k') | pkg/analyzer/lib/src/dart/error/hint_codes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698