Class ReceiverInteriorReturns

java.lang.Object
org.ek9lang.compiler.phase5.ReceiverInteriorReturns

final class ReceiverInteriorReturns extends Object
Item 5, step 2: DERIVE, for user methods and operators, the RETAINS marker the built-ins declare - so a user method that hands back one of its own properties follows the same rule as JSON.get. The marker is ReturnRetention.RECEIVER_INTERIOR, written by ReturnRetention.markReturnsReceiverInterior(MethodSymbol).

A method returns (part of) its receiver when its returning variable is made to refer to (initialiser or a pointer assignment - ReferenceAssignment) any of:

  • this or super;
  • one of its own properties, by bare name;
  • a chain that starts at either and only steps through properties or calls that themselves return their receiver's interior: this.names, names.iterator(), members().first();
  • a call of another of its own methods that returns its receiver's interior: members().

The last two depend on other methods' markers, in any order and across files, so it runs to a FIXPOINT: marks only ever add, so it terminates, and the result does not depend on the order. Anything else - a copy, a constructor, a call on another object, an operator - is not followed, so the method keeps no marker.

Each source is read through ReturnSourceKind - the same classification R5 (CloseableReturnOrError) reads - so the derivation and the error cannot disagree.