toString method

  1. @override
String toString()
override

Dispatches to the script's toString() when there is one, and falls back to _diagnosticString otherwise.

SCD72 wrote the mechanism here; SCE116 moved it to renderInterpretedToString so the enum and extension-type siblings in this file could use it rather than carry a third and fourth copy. The reasoning — why it never throws for anything a script can do, and why two VM errors are the exception — lives on that function.

Implementation

@override
String toString() => renderInterpretedToString(
  target: this,
  method: klass.findInstanceMethod('toString'),
  visitor: klass.declaringVisitor,
  fallback: () => _diagnosticString,
);