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)

Exemptions: conditions inside require, assert, and constrain statements are not flagged. Conditions inside loop bodies are also suppressed because widening has not yet been applied.