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

Unified Diff: pkg/analyzer/lib/src/task/strong/checker.dart

Issue 2352433002: support `@virtual` fields, fix #27384 (Closed)
Patch Set: Created 4 years, 3 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/summary/link.dart ('k') | pkg/analyzer/lib/src/task/strong_mode.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/strong/checker.dart
diff --git a/pkg/analyzer/lib/src/task/strong/checker.dart b/pkg/analyzer/lib/src/task/strong/checker.dart
index 0fd6f26590745d1b76e8192ede98376a7a3e9e42..1183ce39b407921b236f43239d64a9e725cc5651 100644
--- a/pkg/analyzer/lib/src/task/strong/checker.dart
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart
@@ -13,6 +13,7 @@ import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/error/codes.dart' show StrongModeCode;
import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
@@ -74,10 +75,10 @@ Element _getKnownElement(Expression expression) {
/// Return the field on type corresponding to member, or null if none
/// exists or the "field" is actually a getter/setter.
-PropertyInducingElement _getMemberField(
+FieldElement _getMemberField(
InterfaceType type, PropertyAccessorElement member) {
String memberName = member.name;
- PropertyInducingElement field;
+ FieldElement field;
if (member.isGetter) {
// The subclass member is an explicit getter or a field
// - lookup the getter on the superclass.
@@ -1388,9 +1389,10 @@ class _OverrideChecker {
if (isSubclass && element is PropertyAccessorElement) {
// Disallow any overriding if the base class defines this member
- // as a field. We effectively treat fields as final / non-virtual.
- PropertyInducingElement field = _getMemberField(type, element);
- if (field != null) {
+ // as a field. We effectively treat fields as final / non-virtual,
+ // unless they are explicitly marked as @virtual
+ var field = _getMemberField(type, element);
+ if (field != null && !field.isVirtual) {
_checker._recordMessage(
errorLocation, StrongModeCode.INVALID_FIELD_OVERRIDE, [
element.enclosingElement.name,
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | pkg/analyzer/lib/src/task/strong_mode.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698