Class ConstructSafeAccessMarker<C extends org.antlr.v4.runtime.ParserRuleContext>

java.lang.Object
org.ek9lang.compiler.phase5.ConstructSafeAccessMarker<C>
Type Parameters:
C - the construct's parse context.
All Implemented Interfaces:
Consumer<C>

final class ConstructSafeAccessMarker<C extends org.antlr.v4.runtime.ParserRuleContext> extends Object implements Consumer<C>
THE marker of what a construct's pre-flow and control expression prove safe for Optional / Result / Iterator access (E08030) - one class for if, switch, try, while, for and the ternary (it was six near-identical subclasses). The construct is described by three accessors, built by the factories below; each says where that construct keeps its pre-flow and its control expression, and in which scope a proof is safe.

The pre-flow's subject is safe in the construct ONLY when the pre-flow is a guard that skips the construct when the subject is unset (<-, :=? - PreFlowCanSkipBody). A plain := checks nothing: if o := empty() then gate ran its body with an empty o and o.get() threw. Before marking, a pre-flow that re-points a subject the scope AROUND the construct has already proven safe is E08040 - judged here, because the construct's own marking would hide it. Each top-level and conjunct of the control that is an is-set check proves its subject safe in the scope, whatever the other conjuncts are (SafeAccessConjuncts). The pre-flow is processed first, then the control expression.