collectionShape method

Object? collectionShape(
  1. InterpreterVisitor? visitor
)

ghissues77: the native object that gives this instance its shape - the native super-object, else the receiver proxy of a dart:collection base or Iterable on its class chain (an IterableBase subclass is read, printed and is-checked as the iterable its proxy is). Null when it has neither.

Implementation

Object? collectionShape(InterpreterVisitor? visitor) {
  final native = _bridgedSuperObject;
  if (native != null) return native;
  final seen = <InterpretedClass>{};
  Object? walk(InterpretedClass? c) {
    if (c == null || !seen.add(c)) return null;
    for (final bridged in [?c.bridgedSuperclass, ...c.bridgedMixins]) {
      final receiver = _receiverProxyFor(bridged.name, visitor);
      if (receiver is Iterable || receiver is Map) return receiver;
    }
    for (final mixin in c.mixins) {
      final found = walk(mixin);
      if (found != null) return found;
    }
    return walk(c.superclass);
  }

  return walk(klass);
}