Class InjectedSetCheckOrError
java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.phase3.InjectedSetCheckOrError
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.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionInjectedSetCheckOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
Modifier and TypeMethodDescription(package private) voidinjected?,injected ?? other,injected ?: other.(package private) voidA guard whose value is the injected variable:if svc <- injected,if svc ?= injected.
-
Constructor Details
-
InjectedSetCheckOrError
InjectedSetCheckOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
injected?,injected ?? other,injected ?: other. -
accept
A guard whose value is the injected variable:if svc <- injected,if svc ?= injected.
-