Class CloseableErasedByStoreOrError

java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.phase5.CloseableErasedByStoreOrError

final class CloseableErasedByStoreOrError extends RuleSupport
R7 of the closeable ownership rules (Steve, 2026-10-05): closeability cannot be erased by a store (E81059).

A closeable value STORED into a variable, property or returning variable whose DECLARED type is not closeable - x as IO: HTTP(), s as StringInput: TextFile(p).input(), a as Any: Res() - escapes both halves of the ownership rule: the slot's type has no close, so E81056 does not see a closeable local and nothing can ever close it through that name; and the statement that created the value sees a store, so it hands the value on instead of closing it. Nothing ever closes it.

A store is a StoreSite: a declaration with an initialiser (<-, :=, =, :) or a pointer assignment (:=, =, :, :=?) as ReferenceAssignment.repointsTarget(EK9Parser.AssignmentStatementContext) reads it, to a local, a property or the returning variable alike. A merge, copy or other in-place operator hands the value to the target's operator and stores no reference. An ARGUMENT is not a store: passing a CloseableStringInput to a StringInput parameter lends a view, and the owner still closes it.

"Closeable" is CloseableResourceToBeChecked.isManagedCloseableType(ISymbol), the one predicate E81056 and the statement wrap ask, so a slot typed as the Closeable trait (which has close) is a closeable slot, and the global standard streams are never closeable values.