Class RedundantIsSetCheckOrError
java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.TypedSymbolAccess
org.ek9lang.compiler.phase5.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.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionRedundantIsSetCheckOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener, ValueTrackingAnalyzer valueTracker) -
Method Summary
Methods inherited from class TypedSymbolAccess
getRecordedAndTypedSymbol, isProcessingScopePure, recordATypedSymbol
-
Constructor Details
-
RedundantIsSetCheckOrError
RedundantIsSetCheckOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener, ValueTrackingAnalyzer valueTracker)
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceConsumer<EK9Parser.ExpressionContext>
-