| 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 d465b405556fad6a281fb6302d3840935c2c43ba..58c2169dcea689d5b1113b8d6ec94148c7b5cd7b 100644
|
| --- a/pkg/analyzer/lib/src/dart/element/element.dart
|
| +++ b/pkg/analyzer/lib/src/dart/element/element.dart
|
| @@ -2514,6 +2514,12 @@ class ElementAnnotationImpl implements ElementAnnotation {
|
| static String _REQUIRED_VARIABLE_NAME = "required";
|
|
|
| /**
|
| + * The name of the top-level variable used to mark a member as intended to be
|
| + * overridden.
|
| + */
|
| + static String _VIRTUAL_VARIABLE_NAME = "virtual";
|
| +
|
| + /**
|
| * The element representing the field, variable, or constructor being used as
|
| * an annotation.
|
| */
|
| @@ -2616,6 +2622,18 @@ class ElementAnnotationImpl implements ElementAnnotation {
|
| element.library?.name == _META_LIB_NAME;
|
|
|
| /**
|
| + * Return `true` if this annotation marks the associated member as supporting
|
| + * overrides.
|
| + *
|
| + * This is currently used by fields in Strong Mode, as other members are
|
| + * already virtual-by-default.
|
| + */
|
| + bool get isVirtual =>
|
| + element is PropertyAccessorElement &&
|
| + element.name == _VIRTUAL_VARIABLE_NAME &&
|
| + element.library?.name == _META_LIB_NAME;
|
| +
|
| + /**
|
| * Get the library containing this annotation.
|
| */
|
| Source get librarySource => compilationUnit.librarySource;
|
| @@ -4182,6 +4200,16 @@ class FieldElementImpl extends PropertyInducingElementImpl
|
| }
|
|
|
| @override
|
| + bool get isVirtual {
|
| + for (ElementAnnotationImpl annotation in metadata) {
|
| + if (annotation.isVirtual) {
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| +
|
| + @override
|
| ElementKind get kind => ElementKind.FIELD;
|
|
|
| /**
|
|
|