Class SafeAccessRepointOrError


final class SafeAccessRepointOrError extends SafeSymbolAccess
THE E08040 rule: an Optional/Result/Iterator that is proven safe to unwrap in the current scope must not be re-pointed there, by ANY store - an assignment statement (o: other, o :=? other) or a construct's assignment pre-flow (if o := other then o?). The o.get() the safe scope allows would read the NEW value, which nothing checked (it threw 'No such element').

A store that IS the pre-flow of a construct (if/while/for/switch/try o := other) is not judged where it appears: while, for, switch and try mark their WHOLE scope safe for the pre-flow's own subject, so at the store the subject already reads as safe - by itself. The construct's marker judges its pre-flow instead, BEFORE it marks (AbstractSafeGenericAccessMarker), against the scope around the construct. isConstructPreFlow(ParserRuleContext) is the one test for that position.

  • Constructor Details

  • Method Details

    • isConstructPreFlow

      static boolean isConstructPreFlow(org.antlr.v4.runtime.ParserRuleContext store)
      True when this store is a construct's pre-flow, which its construct's marker judges.
    • accept

      void accept(ISymbol target, org.antlr.v4.runtime.Token op)
      Report E08040 at op if target is proven safe to unwrap in the current scope.
    • accept

      A construct's pre-flow, judged by its marker before the marker makes the construct safe. A declaration (if o <- value) makes a new variable, so only an assignment re-points.