@@ -92,8 +92,12 @@ mixin Inheritable on ContainerMember {
92
92
definingEnclosingContainer.isPublic) {
93
93
assert (
94
94
definingEnclosingContainer == found,
95
- 'For $element , expected $definingEnclosingContainer to be Object '
96
- 'or $found , but was neither.' );
95
+ "For '$element ' (${element .hashCode }) "
96
+ "(search element: '$searchElement ', ${searchElement ?.hashCode }, in "
97
+ "'${searchElement ?.enclosingElement }'), expected "
98
+ "'$definingEnclosingContainer ', which is canonical, to be '$found ',"
99
+ "but was not. Here's the inheritance chain: "
100
+ '${inheritance .reversed }.' );
97
101
}
98
102
if (found != null ) {
99
103
return found;
@@ -112,8 +116,19 @@ mixin Inheritable on ContainerMember {
112
116
];
113
117
var object = packageGraph.specialClasses[SpecialClass .object]! ;
114
118
115
- assert (definingEnclosingContainer == object ||
116
- inheritance.contains (definingEnclosingContainer));
119
+ assert (
120
+ definingEnclosingContainer == object ||
121
+ inheritance.contains (definingEnclosingContainer), () {
122
+ var inheritanceDescriptions = inheritance
123
+ .map ((e) =>
124
+ "'$e ' (hashCode: ${e .hashCode }, in library '${e .library }')" )
125
+ .toList ();
126
+ return "Given '$this ', on '$enclosingElement ' in library '$library ', "
127
+ "the defining enclosing container, '$definingEnclosingContainer ' "
128
+ '(hashCode: ${definingEnclosingContainer .hashCode }, '
129
+ "in library '${definingEnclosingContainer .library }'), should have "
130
+ 'been Object or contained in: $inheritanceDescriptions ' ;
131
+ }());
117
132
// Unless the code explicitly extends dart:core's Object, we won't get
118
133
// an entry here. So add it.
119
134
if (inheritance.last != object) {
0 commit comments