Class IsFreshValueExpression

java.lang.Object
org.ek9lang.compiler.support.IsFreshValueExpression
All Implemented Interfaces:
Predicate<EK9Parser.ExpressionContext>

public final class IsFreshValueExpression extends Object implements Predicate<EK9Parser.ExpressionContext>
THE "fresh value" predicate: true iff an expression evaluates to a NEW object - one nothing else holds a reference to. Use this wherever a check needs "fresh"; do not write a second definition (the IR's uniqueness lattice, RAILS D.4, is its twin and must keep the same meaning).

Every reading accepts:

  • Literal — string, integer, boolean, etc.
  • Constructor call — a call whose resolved target is a constructor; the call creates a new instance.
  • Either of those in parentheses.

The closeable-return reading (R5, E81057) also accepts a call of a method, operator or function whose DECLARED return type is closeable and whose RETAINS does not say its result may alias its receiver or an argument (MayAlias). Such a callable is itself bound by R5 to return a new instance, so its declaration is the proof - no fixpoint over callees is needed.

The MutexLock reading (E08257, IsFreshValueExpression(SymbolsAndScopes)) stays strict: a call result there is not fresh, because nothing binds an arbitrary callee to hand back a new payload. Anything else (bare identifier, property access, other call results, pipeline results) is not fresh.