Class CloseSteps

java.lang.Object
org.ek9lang.compiler.support.CloseSteps

public final class CloseSteps extends Object
THE decision of what a type's operator close is responsible for - use it, never re-derive it. "If you hold it, you close it" (Steve, 2026-10-06, D8): every check and every generator that asks "which of this type's fields must its close close?", "which parent close does it chain to?" or "does this type declare its own close?" asks HERE, so the holder-must-close rule (E81067), the vacuous-default rule (E81070), the phase-5 call graph and the generated close chain in phase 7 cannot disagree.
  • isCloseOperator(MethodSymbol) - the method is a type's close operator.
  • of(MethodSymbol) - THE chain: CloseSteps.Steps.closed() (what its close closes, in ACQUISITION order - the generated code closes them last first) and CloseSteps.Steps.parentClose() (the one parent close it then calls, non-virtually).
  • closedProperties(IAggregateSymbol) - the fields its close closes, in acquisition order: first the captures a dynamic class OWNS (a fresh captured expression is a transfer, R-E - marked OWNED_CAPTURE in PRE_IR_CHECKS; captures are constructor arguments, set before any initialiser runs), then its OWN getProperties() in declaration order, keeping those whose type is a managed closeable (CloseableResourceToBeChecked.isManagedCloseableType(ISymbol), so never a bare T and never a standard stream), minus the exclusions (R-G), stated once here:
    • an injected property (store as Store!) - the application's registry owns it;
    • the delegate of a by-delegation proxy close - the proxy forwards close to it, so it is closed already (a class that writes its own close gets no proxy and owns the delegate like any property);
    • a capture that is not fresh (named, (owner: this)) - a borrow: its owner is the scope that made the dynamic class.
  • parentClose(IAggregateSymbol) - the super CLASS's close, when it has a non-abstract one (its own or one it inherits from a class). A trait's close is never chained (D8: a trait's close is abstract, E81066), so neither is Closeable's.
  • declaredClose(IAggregateSymbol) - the close this type DECLARES ITSELF: in its own scope, not abstract and not a delegation proxy. An inherited close never counts - it cannot see a field the sub-type adds (critic c15).
  • isDefaultedClose(MethodSymbol) - the type asked for default operator close.

Inherited properties are the super's to close, through the super's own close - which is why the chain ends in CloseSteps.Steps.parentClose(). A body the developer writes runs FIRST, with everything still open; the chain then runs on every path (it is the body's finally). Nothing is generated when CloseSteps.Steps.isEmpty().

  • Method Details

    • isCloseOperator

      public static boolean isCloseOperator(MethodSymbol method)
      True when the method is a type's close operator.
    • of

      public static CloseSteps.Steps of(MethodSymbol closeOperator)
      THE generated chain of the type a close operator belongs to.
    • of

      public static CloseSteps.Steps of(IAggregateSymbol aggregate)
      THE generated chain of a type's close.
    • closedProperties

      public static List<ISymbol> closedProperties(IAggregateSymbol aggregate)
      The fields the type's close closes, in acquisition order: owned captures, then own closeable properties.
    • ownedCaptures

      public static List<ISymbol> ownedCaptures(IAggregateSymbol aggregate)
      The captures a dynamic class owns: each one PRE_IR_CHECKS marked as a fresh closeable (R-E).
    • isOwnedCapture

      public static boolean isOwnedCapture(ISymbol capture)
      True when the capture was marked as owned by the dynamic class that made it.
    • parentClose

      public static Optional<MethodSymbol> parentClose(IAggregateSymbol aggregate)
      The close of the nearest super CLASS that has one, when it is not abstract. Traits are never consulted.
    • declaredClose

      public static Optional<MethodSymbol> declaredClose(IAggregateSymbol aggregate)
      The close operator this type declares itself, if any: own scope, not abstract, not a delegation proxy.
    • isDefaultedClose

      public static boolean isDefaultedClose(MethodSymbol method)
      True when the operator is a close the developer asked for with default operator close.
    • chainedCloses

      public static List<MethodSymbol> chainedCloses(IAggregateSymbol aggregate)
      Every type a close of this type reaches through its chain - the static types of the closed fields and the owner of the parent close - for the call graph (each is called by the generated close).