Class StreamElementNotCloseableOrError

java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.phase3.StreamElementNotCloseableOrError

final class StreamElementNotCloseableOrError extends RuleSupport
THE rule that a stream's element type is never closeable (E81073, Steve 2026-10-26, decision (a) of the closeables lane) - the stream analogue of E81061, which says a closeable is never a type argument.

A stage whose output element type is closeable (map with makeRes, call, async, a source of closeables) makes a resource per element, in the middle of a pipeline, where no try can name it and no statement owns it: the next stage and the sink only ever see a value that nothing closes - or, into a List of Base, one that is kept after the stream ends. The element type of a stage is not written as a type argument, so E81061 cannot see it: this asks the type the stream carries, at the source and after each stage, with the one predicate the ownership rules share (CloseableResourceToBeChecked.isManagedCloseableType(ISymbol)).

Reported ONCE per stream, at the first place the stream carries a closeable element - a stage that merely passes the same closeable type on (filter, sort) is the same fault, not another one. The fix the message teaches is a for loop whose body names each value as a try resource.

  • Constructor Details

  • Method Details

    • test

      boolean test(IToken location, String producer, ISymbol elementType)
      Parameters:
      location - the source, or the stage, that produces the element type
      producer - the text of the source or stage (cat, map...)
      elementType - the type the stream carries after it
      Returns:
      true iff the element type is closeable and the error was emitted