Class SafeAccessConjuncts
java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.TypedSymbolAccess
org.ek9lang.compiler.phase5.AbstractSafeSymbolMarker
org.ek9lang.compiler.phase5.SafeAccessConjuncts
THE conjunct walk for Optional/Result/Iterator safe access (Steve, 2026-10-07, decision Q3) - use it, never
re-derive a variant. A condition is flattened into its TOP-LEVEL
and conjuncts (the root and
chain, parenthesised and groups included); each conjunct of the form x? (or the named checks
r.isOk(), r.isError(), it.hasNext()) proves its subject set:
- in the body the condition guards (
markProven(EK9Parser.ExpressionContext, IScope)), whatever the other conjuncts are -r? and (count < limit)makesr.get()safe in the body; - inside the expression itself, for a LATER conjunct only, left to right (
isProvenEarlier(ParseTree, ISymbol, CommonValues)) -andshort-circuits, soo? and o.get() > 0is safe ando.get() > 0 and o?is not.
? under or, xor, not, a ternary or a call argument proves
nothing, so (o? and x) or (o? and y) and not not o? make nothing safe.
This replaced the earlier rule that the WHOLE condition had to be a "simple" and of checks.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final recordOne fact a conjunct proves:access(ok/error/get/next) onsymbolis safe. -
Field Summary
Fields inherited from class AbstractSafeSymbolMarker
iteratorTypeCheck, optionalTypeCheck, resultTypeCheckFields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionSafeAccessConjuncts(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
Modifier and TypeMethodDescription(package private) static List<EK9Parser.ExpressionContext> conjunctsOf(EK9Parser.ExpressionContext condition) The top-levelandconjuncts ofcondition, left to right, parentheses removed.(package private) booleanisProvenEarlier(org.antlr.v4.runtime.tree.ParseTree accessSite, ISymbol symbol, CommonValues access) True whenaccessonsymbolataccessSiteis protected by an EARLIER conjunct of an enclosingandevaluated as part of the same expression.(package private) voidmarkProven(EK9Parser.ExpressionContext condition, IScope scopeMadeSafe) Mark everything the top-level conjuncts ofconditionprove as safe inscopeMadeSafe.Methods inherited from class AbstractSafeSymbolMarker
assessIsSetCallMethods inherited from class TypedSymbolAccess
emitTypeNotResolvedError, getRecordedAndTypedSymbol, isProcessingScopePure, recordATypedSymbol
-
Constructor Details
-
SafeAccessConjuncts
SafeAccessConjuncts(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
conjunctsOf
The top-levelandconjuncts ofcondition, left to right, parentheses removed. -
markProven
Mark everything the top-level conjuncts ofconditionprove as safe inscopeMadeSafe. -
isProvenEarlier
boolean isProvenEarlier(org.antlr.v4.runtime.tree.ParseTree accessSite, ISymbol symbol, CommonValues access) True whenaccessonsymbolataccessSiteis protected by an EARLIER conjunct of an enclosingandevaluated as part of the same expression.
-