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

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

Issue 2946273002: Implement override-based type inference for instance methods. (Closed)
Patch Set: 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/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 26b9fa1cfce3f487db3070e0771e7a88e3191a0c..9e5eee90c4cb3e4420fd9d920023c7b270c85c74 100644
--- a/pkg/analyzer/lib/src/task/strong/checker.dart
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart
@@ -1289,14 +1289,19 @@ class _OverrideChecker {
// Check also how we override locally the interfaces from parent classes if
// the parent class is abstract. Otherwise, these will be checked as
// overrides on the concrete superclass.
+ // We detect superclass circularities using the "tortoise and hare"
+ // algorithm.
var superInterfaces = new Set<InterfaceType>();
var parent = type.superclass;
+ var hare = type.superclass?.superclass;
// TODO(sigmund): we don't seem to be reporting the analyzer error that a
// non-abstract class is not implementing an interface. See
// https://github.com/dart-lang/dart-dev-compiler/issues/25
while (parent != null && parent.element.isAbstract) {
+ if (identical(parent, hare)) break;
parent.interfaces.forEach((i) => find(i, superInterfaces));
parent = parent.superclass;
+ hare = hare?.superclass?.superclass;
}
_checkInterfacesOverrides(type, superInterfaces, seen,
includeParents: false, classNode: node);

Powered by Google App Engine
This is Rietveld 408576698