Class IsConvertableToStringOrError

java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.phase3.IsConvertableToStringOrError
All Implemented Interfaces:
BiPredicate<IToken,ISymbol>

class IsConvertableToStringOrError extends RuleSupport implements BiPredicate<IToken,ISymbol>
Checks if a type has the $ 'toString' method or a 'promotion' #^ to a String method. If not emits an error. Or it must be the String type itself. Also sets the appropriate conversion flags on the ExpressionSymbol if provided.
  • Constructor Details

    • IsConvertableToStringOrError

      IsConvertableToStringOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
      Constructor to provided typed access.
  • Method Details

    • test

      public boolean test(IToken errorReportingLocation, ISymbol typeSymbol)
      Specified by:
      test in interface BiPredicate<IToken,ISymbol>
    • testAndSetFlags

      boolean testAndSetFlags(IToken errorReportingLocation, ISymbol typeSymbol, ExpressionSymbol expressionSymbol)
      Test if the type can be converted to String and optionally set flags on the expression symbol.
      Parameters:
      errorReportingLocation - Location for error reporting
      typeSymbol - The type to check
      expressionSymbol - Optional expression symbol to set conversion flags on
      Returns:
      true if type is already String or has $ operator, false if promotion is needed