Class InjectedSetCheckOrError

java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.phase3.InjectedSetCheckOrError

final class InjectedSetCheckOrError extends RuleSupport
An injected component is always set, so any check that it is set is always true - dead code that reads as though the injection might not arrive (E08266). EK9 eliminates it rather than discouraging it.

The checks: injected? wherever it appears (an if/while condition, require, assert, a ternary's control, a returning value, inside not); the coalescing operators injected ?? other and injected ?: other, which fall back only when the left is unset or absent; and a guard whose value is the injected variable itself (if svc <- injected, ?=, :=), whose body always runs.

"Injected" is a variable or property declared name as T!: the symbol the operand resolves to ISymbol.isInjectionExpected(). A value COPIED from it into another variable is an ordinary variable - that is the fallback idiom: chosen <- supplied then chosen :=? injected. Assigning to the injected variable itself, :=? included, is E08170.