Class SafeAccessConjuncts


final class SafeAccessConjuncts extends AbstractSafeSymbolMarker
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: Fail-closed: a ? 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.
  • Constructor Details

  • Method Details

    • markProven

      void markProven(EK9Parser.ExpressionContext condition, IScope scopeMadeSafe)
      Mark everything the top-level conjuncts of condition prove as safe in scopeMadeSafe - unless the rest of the condition, after the proving conjunct, may change the container (if name? and forget(name)): the body runs after all of it (ContainerChangedBetween).
    • provesEveryAccess

      boolean provesEveryAccess(EK9Parser.ExpressionContext condition, ISymbol symbol)
      Does condition prove EVERY access symbol's container guards (get() of an Optional, next() of an Iterator; a Result's ok() and error() are never both proven), with nothing after the proving conjunct that may change it? The trailing condition of a do/while that does is checked before every later pass of its body, so the body's own changes do not reach those passes.
    • isProvenEarlier

      boolean isProvenEarlier(org.antlr.v4.runtime.tree.ParseTree accessSite, ISymbol symbol, CommonValues access)
      True when access on symbol at accessSite is protected by an EARLIER conjunct of an enclosing and evaluated as part of the same expression, and nothing evaluated between that conjunct and the access may change the container (name? and forget(name) and name.get() > 0 is not protected - ContainerChangedBetween).