Class RedundantIsSetCheckOrError

All Implemented Interfaces:
Consumer<EK9Parser.ExpressionContext>

final class RedundantIsSetCheckOrError extends TypedSymbolAccess implements Consumer<EK9Parser.ExpressionContext>
Detects isSet checks that are always true or always false based on data flow analysis (E08088/E08089).

The postfix ? operator in EK9 checks if a variable is set. This checker uses the ValueTrackingAnalyzer to determine when such checks are redundant because the variable is provably SET (e.g., assigned from a literal, or inside a guard's true-branch) or provably UNSET (e.g., declared with ? and never assigned).

Examples detected:

  • x <- "hello"; if x? — always true, string literal is always SET (E08088)
  • if name <- getName() { if name? } — always true, guard proved SET (E08088)
  • name as String?; if name? — always false, declared UNSET never assigned (E08089)

Inside require/assert: only the bug-class NEVER_SET case (E08089) fires. The REDUNDANT case (E08088) is suppressed because require x? is the established idiom for "touch this variable" since EK9 enforces capture and has no discard pattern.

Conditions inside loop bodies are suppressed because widening has not yet been applied.