rewrapPreservingMemberSignal function

RuntimeD4rtException rewrapPreservingMemberSignal(
  1. RuntimeD4rtException e,
  2. String message
)

Re-wraps e under a new message, keeping the "member absent" signal when e carries one.

Several sites add context to a member-lookup failure on the way out ("… (accessing property via PropertyAccess 'x')"). Before SCC28 those preserved the signal by accident: they concatenated the original message into the new one, so an outer contains("Undefined property 'x'") still matched straight through the wrap. Now that the signal is a type, preserving it has to be deliberate — a plain RuntimeD4rtException here would leave the next frame out unable to tell an absent member from a failed one, which is precisely the extension-method regression SCC28 exists to prevent.

The original UndefinedMemberD4rtException.memberName is carried over rather than replaced with the wrapping site's own name: the failure being described is still the inner one, and that is what the substring used to say too.

Implementation

RuntimeD4rtException rewrapPreservingMemberSignal(
  RuntimeD4rtException e,
  String message,
) => e is UndefinedMemberD4rtException
    ? UndefinedMemberD4rtException(message, memberName: e.memberName)
    : RuntimeD4rtException(message);