Class CloseableArgumentKeeping

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

final class CloseableArgumentKeeping extends Object
THE record of which constructor parameters a constructor KEEPS as a closeable property, and the deferred verdict on every construction that hands such a parameter a value that is not new (R4 of the fresh-store rule, E81062).

A constructor that stores its own parameter in a closeable property (held: res) takes ownership of the argument: the holder's operator close will close it. That is a transfer, and it is right only when the caller hands over a NEW value - Holder(Res("x")). Handing it a value that already has an owner - a try resource, a parameter, another object's property - gives that one resource two owners, and both close it (try -> res <- Res() / holder <- Holder(res) closed res twice).

Collected while every source is walked (Walk 1, in parallel), decided once all have been (check()): a constructor in one file is called in another, and a constructor that passes its own parameter on to super(...), this(...) or another keeping constructor keeps it too, which is a fixpoint over all of them. A member of a parameterised type is judged by the generic's own constructor (GenericTemplateMember).

The same record serves EVERY user callable (the lane callee-keep, Steve's rule B + decision A, 2026-10-21): what a method, operator, function or dynamic function does with each of its parameters is read with the same occurrence reading as a constructor's (CallableParameterOccurrences, over ObjectSharing.all), and the answer is DERIVED as RETAINS rules in the vocabulary a built-in declares - receiver <- item (kept in a property), <otherParam> <- item (added to what another argument refers to), ambient <- item (held where nothing here can name it) - so ReturnRetention.retainsArgument reads a user callable exactly as it reads a built-in. They are closed to a fixpoint across calls (a callee forwarding to a callee that keeps) and unioned over every override of a declaration (ReceiverInteriorReturns.overriddenBy); an abstract declaration nothing implements cannot say, so it keeps every argument.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static enum 
    What a construction does with the argument it is given at one position - decided only after every source has been walked (check()).
    (package private) static final record 
    A variable of one callable's body - one of its parameters, or a local that may refer to the same object - compared by identity.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
    Where a kept argument ends up when nothing more precise is known: held where nothing here can name it.
    (package private) static final String
    Where an argument stored in a property of the object ends up.
    (package private) static final String
    The argument is held by what the callable returns: handed back, not kept beyond the result.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    The local to now refers to the same object as from.
    (package private) void
    After every source has been walked: close the kept set over the forwards, derive what every callable keeps, then report every construction that hands a kept parameter a value that is not new.
    (package private) void
    A callable that was walked: what it does with each of its parameters is then known.
    fateOf(MethodSymbol target, int index)
    What the constructor does with the argument given at index.
    (package private) void
    forwards(MethodSymbol constructor, int fromIndex, MethodSymbol target, int toIndex)
    The constructor passes its own parameter at fromIndex to target at toIndex: if the target keeps it, so does this constructor.
    (package private) void
    The variable is passed on, whole, to target's parameter: if that keeps it, so does this callable.
    (package private) void
    keeps(MethodSymbol constructor, int index)
    The constructor stores its parameter at index in a closeable property of the object it constructs.
    (package private) void
    The object a variable refers to is kept beyond the call (a property, a container...), in destination: RECEIVER, the name of another parameter, or AMBIENT.
    (package private) void
    notFresh(MethodSymbol target, int index, ErrorListener errorListener, IToken location, String argument)
    A construction is given a closeable value that is not new at index: an error when the constructor keeps that parameter.
    (package private) void
    passedToCall(CloseableArgumentKeeping.Holder from, ScopedSymbol callee, int argumentIndex)
    The variable is passed, whole, to a method or function of the program's own.
    (package private) void
    The object a method runs on - Holder.of(method, null), its receiver - is passed on, as the receiver, to a method of the program's own: if that method keeps ITS receiver, so does this one.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • AMBIENT

      static final String AMBIENT
      Where a kept argument ends up when nothing more precise is known: held where nothing here can name it.
      See Also:
    • RECEIVER

      static final String RECEIVER
      Where an argument stored in a property of the object ends up.
      See Also:
    • RETURN

      static final String RETURN
      The argument is held by what the callable returns: handed back, not kept beyond the result.
      See Also:
  • Constructor Details

    • CloseableArgumentKeeping

      CloseableArgumentKeeping()
  • Method Details

    • declared

      void declared(ScopedSymbol callable)
      A callable that was walked: what it does with each of its parameters is then known.
    • keepsOpen

      void keepsOpen(CloseableArgumentKeeping.Holder holder, String destination)
      The object a variable refers to is kept beyond the call (a property, a container...), in destination: RECEIVER, the name of another parameter, or AMBIENT.
    • aliases

      void aliases(CloseableArgumentKeeping.Holder from, ISymbol to)
      The local to now refers to the same object as from.
    • forwardsOpen

      void forwardsOpen(CloseableArgumentKeeping.Holder from, MethodSymbol target, int toIndex)
      The variable is passed on, whole, to target's parameter: if that keeps it, so does this callable.
    • passedToCall

      void passedToCall(CloseableArgumentKeeping.Holder from, ScopedSymbol callee, int argumentIndex)
      The variable is passed, whole, to a method or function of the program's own.
    • receiverPassed

      void receiverPassed(CloseableArgumentKeeping.Holder from, ScopedSymbol callee)
      The object a method runs on - Holder.of(method, null), its receiver - is passed on, as the receiver, to a method of the program's own: if that method keeps ITS receiver, so does this one.
    • fateOf

      CloseableArgumentKeeping.Fate fateOf(MethodSymbol target, int index)
      What the constructor does with the argument given at index. Only valid after check().
    • keeps

      void keeps(MethodSymbol constructor, int index)
      The constructor stores its parameter at index in a closeable property of the object it constructs.
    • forwards

      void forwards(MethodSymbol constructor, int fromIndex, MethodSymbol target, int toIndex)
      The constructor passes its own parameter at fromIndex to target at toIndex: if the target keeps it, so does this constructor.
    • notFresh

      void notFresh(MethodSymbol target, int index, ErrorListener errorListener, IToken location, String argument)
      A construction is given a closeable value that is not new at index: an error when the constructor keeps that parameter.
    • check

      void check()
      After every source has been walked: close the kept set over the forwards, derive what every callable keeps, then report every construction that hands a kept parameter a value that is not new. Writes squirrelled data (the derived RETAINS): run under the program lock.