Class CloseableNotInGenericParameterOrError
- All Implemented Interfaces:
Predicate<ParameterisedTypeData>
A closeable value has exactly one owner, and the compiler must be able to see that owner close it: a try
resource, a property closed in its type's operator close, or the caller of a callable that returns a
new one. A generic type or function has no such owner - List of TCP, Optional of TCP,
Dict of (String, HTTP), a user Box of Res or Acceptor of TCP hold or pass the value
where no operator close and no try reach it. So the parameterisation is refused whether it is
written (List of TCP) or inferred ([TCP(...)], Optional(res), {k: res}, a
generic function called with a closeable) - both reach here through ResolverOrDefiner. A closeable
may still be a PARAMETER type: that is a loan, and the lender keeps ownership.
What is closeable is CloseableResourceToBeChecked.isManagedCloseableType(ISymbol), the one predicate the
ownership rules share (the standard streams and a bare conceptual T are not). The other half of the
rule - a generic's T constrain by Res with Res closeable - is in phase 2's
SetupGenericTOrError, which asks the same predicate.
There is NO exemption for the compiler's own parameterisations: SynthesizeSuperFunction, which gives a
function its implicit Acceptor of T / Consumer of T / Supplier of T ... super, declines
to synthesise one over a closeable type (its super is then Any), so this rule holds on every path (D7,
Steve 2026-10-06 - the exemption, the four synthesised wrappers over TCP/HTTP and their unresolved-call ratchet
bump were removed together).
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionCloseableNotInGenericParameterOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
-
Constructor Details
-
CloseableNotInGenericParameterOrError
CloseableNotInGenericParameterOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
test
- Specified by:
testin interfacePredicate<ParameterisedTypeData>- Returns:
trueiff an error was emitted (the parameterisation is invalid), matching the other guard predicates onResolverOrDefiner.
-