hashCode property
Honour user-defined hashCode so that interpreted instances slot into
native Dart hash structures consistently with their ==. Mirror of
tom_d4rt InterpretedInstance.hashCode.
Implementation
@override
int get hashCode {
final hc = klass.findInstanceGetter('hashCode');
if (hc == null) return super.hashCode;
final visitor = D4.activeVisitor;
if (visitor == null) return super.hashCode;
final id = identityHashCode(this);
if (!_hashCodeInProgress.add(id)) {
return id;
}
Object? result;
try {
result = hc.bind(this).call(visitor, const <Object?>[], const {});
} on ReturnException catch (e) {
result = e.value;
} catch (_) {
return super.hashCode;
} finally {
_hashCodeInProgress.remove(id);
}
return result is int ? result : super.hashCode;
}