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.

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 ReturnRetention.mayAlias(ScopedSymbol) and ReturnRetention.retainsArgument(ScopedSymbol, int) exactly as a built-in's declaration is.

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

  • Method Details

    • derive

      static void derive(Collection<MutatedOnlyVariables.ReturningCallable> callables)
      Mark every callable that returns its receiver's interior or a parameter. Writes squirrelled data: run under the lock.
    • overriddenBy

      static List<ScopedSymbol> overriddenBy(ScopedSymbol callable)
      The declarations a call through which may run callable: those it overrides, or its super function - THE "what may a call through this declaration run" of the dispatch union, shared with the callee-keep derivation (CloseableArgumentKeeping), so what an override RETURNS and what it KEEPS are unioned over the same set.
    • dispatchedHandlers

      static List<Map.Entry<ScopedSymbol, ScopedSymbol>> dispatchedHandlers(Collection<? extends ScopedSymbol> callables)
      THE dispatcher half of "what may a call through this declaration run" (the closeable route-matrix verifier, 2026-10-22): a call to a dispatcher entry point runs, at run time, the handler most specific to its argument's type - so the entry returns and keeps whatever any of its handlers does. Each pair is (entry, handler), drawn from DispatcherHandlers, the handler set phase 7 dispatches over, for every aggregate one of callables belongs to (a sub-type that adds a handler to an inherited entry is such an aggregate). Empty, and cheap, when no callable is named like a dispatcher entry. Without it a function that hands its loaned argument to router.process(item) - the entry only reads it, the Res handler keeps it - was a loan: the statement closed the closeable the router then used.
    • unionDispatchedHandlers

      static boolean unionDispatchedHandlers(List<Map.Entry<ScopedSymbol, ScopedSymbol>> pairs)
      Record on each dispatcher entry what its handlers return and keep; true when an entry gained a rule.
    • isUserDeclaration

      static boolean isUserDeclaration(ScopedSymbol declaration)
      A declaration whose retention was not DECLARED by a built-in: derived marks only.
    • mayOverride

      static boolean mayOverride(ScopedSymbol callable)
      A method of an aggregate (dynamic classes included), or a function (dynamic functions included).