Class CapturedCloseableOwnershipOrError

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

final class CapturedCloseableOwnershipOrError extends Object
Capture ownership by FRESHNESS (R-E, Steve 2026-10-06) - never by the named/unnamed syntax of the capture.
  • A dynamic CLASS that captures a NEW closeable ((res: Res("x"))) takes it over: the capture is marked OWNED_CAPTURE, so CloseSteps counts it as a field the class holds - the class must declare its own close (E81067) and its generated close closes it.
  • A dynamic FUNCTION has no close, so a NEW closeable it captured could never be closed: E81069.
  • Anything that is not new - a named variable, (owner: this), a property - is a BORROW: its owner is the scope that made the dynamic construct, so it is neither marked nor an error (critic c11, the dynamic-class view of this, keeps compiling and is closed once, by its real owner).

"New" is THE fresh predicate, IsFreshValueExpression.forCloseableReturns(Function) - the same one the fresh-store rule (E81062) uses for every other closeable slot. Marked here, in Walk 1 on entering the construct, so the holder rule on exit, the call graph (Walk 2) and IR generation all read the same mark.