Add sanity check assert int class hierarchy
Change-Id: Iddcf2b64f745bb9385fb5b1621afa68056da89a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103127
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
diff --git a/pkg/kernel/lib/class_hierarchy.dart b/pkg/kernel/lib/class_hierarchy.dart
index 51f0730..474f907 100644
--- a/pkg/kernel/lib/class_hierarchy.dart
+++ b/pkg/kernel/lib/class_hierarchy.dart
@@ -810,9 +810,23 @@
_buildInterfaceMembers(class_, info, setters: false);
}
+ assert(sanityCheckAlsoKnowsParentAndLibrary());
+
return this;
}
+ bool sanityCheckAlsoKnowsParentAndLibrary() {
+ for (Class c in _infoFor.keys) {
+ if (!knownLibraries.contains(c.enclosingLibrary)) {
+ throw new StateError("Didn't know library of $c (from ${c.fileUri})");
+ }
+ if (c.supertype != null && _infoFor[c.supertype.classNode] == null) {
+ throw new StateError("Didn't know parent of $c (from ${c.fileUri})");
+ }
+ }
+ return true;
+ }
+
@override
Supertype asInstantiationOf(Supertype type, Class superclass) {
// This is similar to getTypeAsInstanceOf, except that it assumes that