Index: lib/src/utils.dart |
diff --git a/lib/src/utils.dart b/lib/src/utils.dart |
index 1837b684905de08f9bc3d8d553f417043b11477d..12a5081f1c85e761625f4464b5c1d45e26560852 100644 |
--- a/lib/src/utils.dart |
+++ b/lib/src/utils.dart |
@@ -424,3 +424,16 @@ Map<String, DartType> getObjectMemberMap(TypeProvider typeProvider) { |
} |
return map; |
} |
+ |
+/// Searches all supertype, in order of most derived members, to see if any |
+/// [match] a condition. If so, returns the first match, otherwise returns null. |
+InterfaceType findSupertype(InterfaceType type, bool match(InterfaceType t)) { |
+ for (var m in type.mixins.reversed) { |
+ if (match(m)) return m; |
+ } |
+ var s = type.superclass; |
+ if (s == null) return null; |
+ |
+ if (match(s)) return type; |
+ return findSupertype(s, match); |
+} |