bindsInterfaceMember method
Returns a map representing all members required by the interfaces implemented
by this class and its superclasses, including those from super-interfaces.
Key: member name, Value: String indicating type ('method', 'getter', 'setter')
ghissues71: whether the interface member name binds this class. A
library's _ members are private to it, so they are part of the
interface only for a class of the same library: string_scanner's
SpanScanner implements LineScanner need not implement LineScanner's
_adjustLineAndColumn. A public name always binds. The library is the
environment a class was declared in, which its library's parts share.
Implementation
bool bindsInterfaceMember(String name) {
if (!name.startsWith('_')) return true;
final visited = <InterpretedClass>{};
final queue = <InterpretedClass>[...interfaces];
for (
var current = superclass;
current != null;
current = current.superclass
) {
queue.add(current);
}
while (queue.isNotEmpty) {
final current = queue.removeAt(0);
if (!visited.add(current)) continue;
if (identical(
current.classDefinitionEnvironment,
classDefinitionEnvironment,
) &&
(current.methods.containsKey(name) ||
current.getters.containsKey(name) ||
current.setters.containsKey(name))) {
return true;
}
queue.addAll(current.interfaces);
}
return false;
}