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

Unified Diff: pkg/kernel/lib/class_hierarchy.dart

Issue 2946733003: Fix type inference of getters that "override" setters and vice versa. (Closed)
Patch Set: Address code review comments Created 3 years, 6 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
Index: pkg/kernel/lib/class_hierarchy.dart
diff --git a/pkg/kernel/lib/class_hierarchy.dart b/pkg/kernel/lib/class_hierarchy.dart
index b756146a2a2e00a389f9f68582ac0003f1f320ab..f7c1f852f50feeb38c824316f0f9a7d7f51209c5 100644
--- a/pkg/kernel/lib/class_hierarchy.dart
+++ b/pkg/kernel/lib/class_hierarchy.dart
@@ -115,13 +115,30 @@ abstract class ClassHierarchy {
///
/// By default getters and setters are overridden separately. The [isSetter]
/// callback parameter determines which type of access is being overridden.
- ///
- /// However if [crossGettersSetters] is set to `true`, getters might be
- /// reported as overriding setters, and vice versa - setter overriding
- /// getters. The callback should check the [Procedure.kind] property.
void forEachOverridePair(Class class_,
- callback(Member declaredMember, Member interfaceMember, bool isSetter),
- {bool crossGettersSetters: false});
+ callback(Member declaredMember, Member interfaceMember, bool isSetter));
+
+ /// Invokes [callback] for every function, field, or getter declared in
+ /// [class_] that has a corresponding setter in a supertype of [class_], and
+ /// for every setter or non-final field declared in [class_] that has a
+ /// corresponding function, field, or getter in a supertype of [class_].
+ ///
+ /// We use the term "inheritable" for members that are candidates for
+ /// inheritance but may have been overridden. The "declared" members of a
+ /// mixin application are those declared in the mixed-in type. The callback is
+ /// invoked in the following case:
+ ///
+ /// A member declared in the class overrides a member inheritable through
+ /// one of the supertypes of the class.
+ ///
+ /// This method will not report that a member overrides itself. A given pair
+ /// may be reported multiple times when there are multiple inheritance paths
+ /// to the overridden member.
+ ///
+ /// By default getters and setters are overridden separately. The [isSetter]
scheglov 2017/06/26 20:29:12 "By default getters and setters are overridden sep
Paul Berry 2017/06/27 20:53:30 Thanks! https://codereview.chromium.org/296003300
+ /// callback parameter corresponds to whether [declaredMember] is a setter.
+ void forEachCrossOverridePair(Class class_,
+ callback(Member declaredMember, Member interfaceMember, bool isSetter));
/// This method is invoked by the client after it changed the [classes], and
/// some of the information that this hierarchy might have cached, is not
@@ -396,10 +413,6 @@ class ClosedWorldClassHierarchy implements ClassHierarchy {
isSetter: true);
_reportOverrides(info.declaredSetters, superSetters, callback,
isSetter: true, onlyAbstract: true);
- if (crossGettersSetters) {
- _reportOverrides(info.declaredGettersAndCalls, superSetters, callback);
- _reportOverrides(info.declaredSetters, superGetters, callback);
- }
}
if (!class_.isAbstract) {
// If a non-abstract class declares an abstract method M whose
@@ -417,6 +430,21 @@ class ClosedWorldClassHierarchy implements ClassHierarchy {
}
}
+ @override
+ void forEachCrossOverridePair(Class class_,
+ callback(Member declaredMember, Member interfaceMember, bool isSetter),
+ {bool crossGettersSetters: false}) {
+ _ClassInfo info = _infoFor[class_];
+ for (var supertype in class_.supers) {
+ var superclass = supertype.classNode;
+ var superGetters = getInterfaceMembers(superclass);
+ var superSetters = getInterfaceMembers(superclass, setters: true);
+ _reportOverrides(info.declaredGettersAndCalls, superSetters, callback);
+ _reportOverrides(info.declaredSetters, superGetters, callback,
+ isSetter: true);
+ }
+ }
+
static void _reportOverrides(
List<Member> declaredList,
List<Member> inheritedList,

Powered by Google App Engine
This is Rietveld 408576698