Class PreFlowCanSkipBody
A pre-flow (the head of an if/while/do/for/switch/try)
is a body-skipping guard iff its operator performs an isSet check that can skip the body:
<-(EK9Parser.LEFT_ARROW) - declaration guard:=?(EK9Parser.ASSIGN_UNSET) - assign-if-unset guard
A plain :=/= assignment (EK9Parser.ASSIGN/EK9Parser.ASSIGN2) is NOT a
guard - the body always runs unless the control says otherwise (if x := f() then x? is the explicit
re-point-and-gate that replaced the removed ?= guard, Steve 2026-10-07, D3). A null pre-flow is
not a guard.
This is the SOLE authority, consumed by BOTH phase 5 and phase 7, so the two phases can never drift on
what a guard is (that drift was the root cause of a null-safety bug where an expression-form return
declared as T? could be left as a raw Java null on the skip path):
- Phase 5 uses it to decide when an expression-form return MUST be initialised
(
RETURN_NOT_ALWAYS_INITIALISED/ E08050) - a skippable body means the return's initial value is the result on the skip path, so an uninitialised<- rtn as T?is an error. - Phase 7 uses it (via
GuardedConditionEvaluator.requiresGuardCheck) to decide whether to emit a guard entry-check that gates the body.
Do NOT re-derive a variant of this classification - call this.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanTrue iff this pre-flow is a body-skipping guard (<-,:=?).static Optional<org.antlr.v4.runtime.tree.ParseTree> THE node whose recorded symbol is a guard's TARGET - the variable its implicit gate set-checks: thevariableDeclarationofv <- e(), or the identifier ofv :=? e().static booleanoperatorCanSkipBody(Integer operatorType) True iff this pre-flow operator token type is a body-skipping guard operator.
-
Method Details
-
canSkipBody
True iff this pre-flow is a body-skipping guard (<-,:=?).- Parameters:
preFlow- the pre-flow statement context (may be null)- Returns:
- true if the pre-flow can skip the construct body
-
operatorCanSkipBody
True iff this pre-flow operator token type is a body-skipping guard operator. The token-level entry point so phase 7 (which already resolves the operator type) can share the exact same classification without re-deriving it.- Parameters:
operatorType- the pre-flow operator token type (may be null)- Returns:
- true if the operator can skip the construct body
-
guardTargetNode
public static Optional<org.antlr.v4.runtime.tree.ParseTree> guardTargetNode(EK9Parser.PreFlowStatementContext preFlow) THE node whose recorded symbol is a guard's TARGET - the variable its implicit gate set-checks: thevariableDeclarationofv <- e(), or the identifier ofv :=? e(). Empty when the pre-flow is not a guard (canSkipBody(EK9Parser.PreFlowStatementContext)) or a:=?assigns something other than a plain identifier (this.x :=? e()). Shared by the Boolean truth guard and the redundant-gate checks (E08086-E08089).- Parameters:
preFlow- the pre-flow statement context (may be null)- Returns:
- the node to read the target's recorded symbol from, if this pre-flow is a guard on a plain variable
-