Class Pattern

All Implemented Interfaces:
TypeConstants, TypeIds
Direct Known Subclasses:
EitherOrMultiPattern, GuardedPattern, RecordPattern, TypePattern

public abstract class Pattern extends Expression
  • Field Details

    • accessorMethod

      protected MethodBinding accessorMethod
    • index

      public int index
    • isUnguarded

      public boolean isUnguarded
    • outerExpressionType

      protected TypeBinding outerExpressionType
  • Constructor Details

    • Pattern

      public Pattern()
  • Method Details

    • getEnclosingPattern

      public Pattern getEnclosingPattern()
    • setEnclosingPattern

      public void setEnclosingPattern(RecordPattern enclosingPattern)
    • isUnnamed

      public boolean isUnnamed()
    • coversType

      public boolean coversType(TypeBinding type, Scope scope)
      Implement the rules in the spec under 14.11.1.1 Exhaustive Switch Blocks
      Returns:
      whether pattern covers the given type or not
    • matchFailurePossible

      public boolean matchFailurePossible()
    • isUnconditional

      public boolean isUnconditional(TypeBinding t, Scope scope)
    • generateCode

      public abstract void generateCode(BlockScope currentScope, CodeStream codeStream, BranchLabel patternMatchLabel, BranchLabel matchFailLabel)
    • generateTestingConversion

      public void generateTestingConversion(BlockScope scope, CodeStream codeStream)
    • checkUnsafeCast

      public boolean checkUnsafeCast(Scope scope, TypeBinding castType, TypeBinding expressionType, TypeBinding match, boolean isNarrowing)
      Overrides:
      checkUnsafeCast in class Expression
    • getType

      public TypeReference getType()
    • isApplicable

      protected boolean isApplicable(TypeBinding expressionType, BlockScope scope, ASTNode location)
    • dominates

      public abstract boolean dominates(Pattern p)
    • print

      public StringBuilder print(int indent, StringBuilder output)
      Overrides:
      print in class Expression
    • getAlternatives

      public Pattern[] getAlternatives()
    • setIsEitherOrPattern

      public abstract void setIsEitherOrPattern()
    • setOuterExpressionType

      public void setOuterExpressionType(TypeBinding expressionType)
    • isUnguarded

      public boolean isUnguarded()
    • setIsGuarded

      public void setIsGuarded()
    • isBoxing

      public static boolean isBoxing(TypeBinding provided, TypeBinding expected)
    • findPrimitiveConversionRoute

      public static Pattern.PrimitiveConversionRoute findPrimitiveConversionRoute(TypeBinding destinationType, TypeBinding expressionType, Scope scope)