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 MarkReturnsReceiverInterior.

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();
  • a LOCAL made to refer to any of these, a wrapper (an Optional, a list literal, a constructor that keeps its argument) built on one, or a dynamic class or function that captures one (ReturnSourceOrigins; option B slices A and D, 2026-11-13).

The last depend on other methods' markers and on the keep side's verdicts, in any order and across files, so it runs to a FIXPOINT - ONE fixpoint with the keep side (CloseableArgumentKeeping), driven by RetentionDerivation: prepare(Collection, Collection) once, then derivePass() until nothing changes. Marks only ever add, so it terminates, and the result does not depend on the order. Anything else - a copy, a call on another object that returns nothing held, an operator - is not followed, so the method keeps no marker.

A method, operator or FUNCTION whose returning variable is made to refer to one of its own parameters records return <- <parameter> the same way (a function identity(x) hands back its argument, so what a caller does to the result it does to the argument) - read by MayAlias and RetainsArgument exactly as a built-in's declaration is.

Each source is read through ReturnSourceClassifier - the same classification R5 (CloseableReturnOrError) reads - so the derivation and the error cannot disagree; what it may be of the callable's inputs is ReturnSourceOrigins. Hold one; it was the static derive (no-statics lane P2, 2026-10-29), and its dispatch-union steps are OverriddenBy, DispatchedHandlerPairs, UnionDispatchedHandlers, IsUserDeclaration and MayOverride; a body-less dynamic function takes its super function's rules by InheritedRules (slice B).

  • Constructor Details

    • ReceiverInteriorReturns

      ReceiverInteriorReturns(CloseableArgumentKeeping keeping)
      Parameters:
      keeping - the keep side of the same fixpoint, whose constructor verdicts the wrapper rule reads.
  • Method Details

    • prepare

      Before the fixpoint: which callables are derived (one that already declares its retention - a built-in walked at bootstrap - keeps exactly what it declares), the dispatch union's sets, the abstract declarations nothing implements, and the body-less dynamic functions.
    • derivePass

      boolean derivePass()
      One pass: each callable returns what its sources are, in terms of its own parameters and receiver; then the inherited rules and the dispatch unions. A source that is a call reads the marks of the callee, so what one callable gains another may gain from it: true when any mark changed, so the driver runs another pass. Writes squirrelled data: run under the lock.