Class PossibleExpressionConstruct

Direct Known Subclasses:
ForStatementOrError, SwitchStatementOrError, TryStatementOrError, WhileStatementOrError

abstract class PossibleExpressionConstruct extends TypedSymbolAccess
Used as a base for a range of constructs that can be expressions.
  • Constructor Details

  • Method Details

    • isVariableInitialisedInScopes

      protected boolean isVariableInitialisedInScopes(CodeFlowAnalyzer analyzer, ISymbol variable, List<IScope> scopes)
    • getGuardExpressionVariable

      protected Optional<ISymbol> getGuardExpressionVariable(EK9Parser.PreFlowStatementContext ctx)
    • getGuardExpressionVariable

      protected Optional<ISymbol> getGuardExpressionVariable(EK9Parser.PreFlowAndControlContext ctx)
    • processPossibleGuardInitialisation

      protected void processPossibleGuardInitialisation(CodeFlowAnalyzer analyzer, ISymbol guardVariable, org.antlr.v4.runtime.ParserRuleContext ctx)
      Now when there is a preflow control, it may mean that a variable is initialised.
    • pullUpAcceptableCriteriaToHigherScope

      protected void pullUpAcceptableCriteriaToHigherScope(CodeFlowAnalyzer analyzer, List<IScope> allAppropriateBlocks, IScope outerScope)
    • returningVariableValidOrError

      protected void returningVariableValidOrError(EK9Parser.ReturningParamContext ctx, IScope constructScope, boolean bodyGuaranteedToRun)
      Validates the returning variable of an expression-form construct.

      When the body is NOT guaranteed to run - a body-skipping guard (<-/?=/:=?, see PreFlowCanSkipBody) can bypass it, or a loop can iterate zero times - a return declared with no initial value (<- rtn as T?) could be left unset on the skip path, so it MUST carry a declaration initialiser. Enforced uniformly across switch/while/do/for/try (before this it fired only for ?= on some constructs and relied on a per-construct backstop, which let switch/for/for-range leak a raw Java null into the LHS at runtime).