Class CloseableSlotStoreOrError

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

final class CloseableSlotStoreOrError extends Object
THE fresh-store rule for closeable SLOTS (R-A, Steve 2026-10-06, decisions D3 and D9, with R-D): every closeable object has exactly ONE owner, so a closeable value may enter a slot that will close it only when nothing else already owns it.

The slots are a closeable PROPERTY (its type's operator close closes it) and a try-with-resources RESOURCE (the try closes it). A local is E81056, the returning variable E81057, a slot of a non-closeable type E81059; a dynamic construct's capture is decided with the capture-ownership rule (R-E). For a StoreSite whose slot and value are both closeable (CloseableResourceToBeChecked.isManagedCloseableType(ISymbol)):

  • E81062 - the value must be NEW, as IsFreshValueExpression.forCloseableReturns(Function) reads it (a constructor call, or a call whose declaration returns a new closeable). A constructor's own parameter stored in one of its properties is the one exception: that is a TRANSFER, and every construction must then hand the parameter a new value (CloseableArgumentKeeping, the R4 half). A parameter transferred twice has two owners and is the same error.
  • E81063 - a closeable SLOT is assigned once (D3, extended 2026-10-06 from properties to every closeable slot). A closeable property is set in its own initialiser or in its own type's constructor, on the object being constructed, while it holds nothing yet. A closeable RETURNING variable (of a function, method, operator, dynamic function, or a switch/try/while/for expression) that is initialised at its declaration is never assigned again, and one declared unset (<- rtn as Res?) is assigned at most once on any path. A try-with-resources RESOURCE is never assigned again: its try closes only what it then holds. Any other assignment (:=, :, =, :=?) re-points the slot and drops what it held: :=? too, because a closeable that failed or closed is present but unset, and the guard replaces it without closing it. "May already hold" is the MUST-set path state plus SlotAssignedOnce, its MAY half (a value set on some paths, or in a loop body).
  • E81064 - closeable properties are closed in reverse DECLARATION order, which is reverse ACQUISITION order only when a constructor acquires them in declaration order: setting one while a closeable property declared after it already holds a value (its initialiser ran, or this path set it) is an error.

Injected properties (x as T!) belong to the application that registered them and are never assigned.

  • Constructor Details

  • Method Details

    • accept

      void accept(EK9Parser.VariableDeclarationContext ctx, boolean isTryResource)
      A declaration with an initialiser: a property's initialiser, or a try-with-resources resource.
    • accept

      A pointer assignment to a variable or property.
    • acceptConstruction

      void acceptConstruction(EK9Parser.CallContext ctx)
      Every argument of a construction that is a closeable value but not a new one: the constructor may keep it (decided after every source is walked), and a constructor passing on its own parameter keeps what the constructor it calls keeps.
    • acceptCallableDeclaration

      void acceptCallableDeclaration(ISymbol recorded)
      A callable declaration (a constructor, method, operator, function or dynamic function): what it does with each of its parameters is then known, so an unnamed closeable given to it is a loan unless it keeps the argument (the verdict of a constructor is CloseableArgumentKeeping.fateOf(MethodSymbol, int); of any other callable, its derived RETAINS).
    • acceptOccurrence

      void acceptOccurrence(EK9Parser.IdentifierContext ctx)
      One occurrence of a callable's own variable - a parameter, or a local that may refer to the same object: does the object outlive the call? THE reading is CallableParameterOccurrences, over ObjectSharing.all(EK9Parser.IdentifierContext, Function) (D78 verifier, 2026-10-21: the store-only reading judged a constructor that put its parameter in a local, a capture, a collection, an Optional or a stream a LOAN, and the closed resource was then used; the lane callee-keep gave a function or method the same reading).
    • acceptSelf

      void acceptSelf(EK9Parser.PrimaryReferenceContext ctx)
      One this or super of a method: does the object the method runs on outlive the call (D80 follow-up, 2026-10-21)? Read as a parameter's object is, by CallableParameterOccurrences.acceptSelf(EK9Parser.PrimaryReferenceContext).
    • acceptCall

      void acceptCall(EK9Parser.CallContext ctx)
      A call of the program's own method with no receiver written (register(items)) passes the object the calling method runs on, as its receiver.