Class PreFlowCanSkipBody
- All Implemented Interfaces:
Predicate<EK9Parser.PreFlowStatementContext>
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 (
GuardedConditionEvaluator,LoopGuardHelper, the switch) to decide whether to emit a guard entry-check that gates the body.
Do NOT re-derive a variant of this classification - hold one of these and ask it. Built on it:
GuardTargetNode (the variable a guard set-checks), GuardSkipsWholeSwitchOrTry (D40) and
PreFlowOperatorToken (the operator token itself).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleantest(EK9Parser.PreFlowStatementContext preFlow) True iff this pre-flow is a body-skipping guard (<-,:=?).
-
Constructor Details
-
PreFlowCanSkipBody
public PreFlowCanSkipBody()
-
-
Method Details
-
test
True iff this pre-flow is a body-skipping guard (<-,:=?).- Specified by:
testin interfacePredicate<EK9Parser.PreFlowStatementContext>- Parameters:
preFlow- the pre-flow statement context (may be null)- Returns:
- true if the pre-flow can skip the construct body
-