Class PreFlowCanSkipBody

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

public final class PreFlowCanSkipBody extends Object implements Predicate<EK9Parser.PreFlowStatementContext>
THE single definition of "can this control-flow pre-flow skip the construct body?".

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:

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 Details

    • PreFlowCanSkipBody

      public PreFlowCanSkipBody()
  • Method Details