Class CloseableHolderDeclaresCloseOrError

java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.TypedSymbolAccess
org.ek9lang.compiler.phase5.CloseableHolderDeclaresCloseOrError
All Implemented Interfaces:
Consumer<org.antlr.v4.runtime.tree.ParseTree>

final class CloseableHolderDeclaresCloseOrError extends TypedSymbolAccess implements Consumer<org.antlr.v4.runtime.tree.ParseTree>
If you hold it, you close it (E81067, Steve 2026-10-06, D8/C5): a class, record, component or dynamic class with a closeable property - or a capture it owns (R-E) - must DECLARE its own operator close: default operator close or one it writes. "Declares", not "has": an inherited close cannot see a property the sub-type adds, so a sub-type relying on its super's close leaked its own property (critic c15), and Closeable's close is a no-op.

And the converse (E81070): a default operator close with nothing to close - no closeable field and no super class close - would only make the type closeable, which forces every caller into a try.

The fields counted, the parent close, and what counts as declaring a close are CloseSteps's - THE field set the generated close chain uses, with its exclusions (injected properties, a by-delegation proxy's delegate, a bare T, a capture that is only borrowed). The rule promises only that a holder closes what it holds; it does not claim that every closeable value is closed.

E81067 is reported on the first closeable field, naming them all, so it never competes with the type-level checks on the type's own name; E81070 on the close of the default operator close.

  • Constructor Details

  • Method Details

    • accept

      public void accept(org.antlr.v4.runtime.tree.ParseTree node)
      Specified by:
      accept in interface Consumer<org.antlr.v4.runtime.tree.ParseTree>