Class TypeHelper

java.lang.Object
com.github.javaparser.symbolsolver.resolution.typeinference.TypeHelper

public class TypeHelper extends Object
The term "type" is used loosely in this chapter to include type-like syntax that contains inference variables. Assertions that involve inference variables are assertions about every proper type that can be produced by replacing each inference variable with a proper type.
Author:
Federico Tomassetti
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    areCompatibleThroughWideningPrimitiveConversion(com.github.javaparser.resolution.types.ResolvedType s, com.github.javaparser.resolution.types.ResolvedType t)
     
    static boolean
    areCompatibleThroughWideningReferenceConversion(com.github.javaparser.resolution.types.ResolvedType s, com.github.javaparser.resolution.types.ResolvedType t)
     
    static MethodType
    getFunctionType(com.github.javaparser.resolution.types.ResolvedType type)
     
    static com.github.javaparser.resolution.types.ResolvedType
    glb(Set<com.github.javaparser.resolution.types.ResolvedType> types)
    See JLS 5.1.10.
    static com.github.javaparser.utils.Pair<com.github.javaparser.resolution.types.ResolvedType, Boolean>
    groundTargetTypeOfLambda(com.github.javaparser.ast.expr.LambdaExpr lambdaExpr, com.github.javaparser.resolution.types.ResolvedType T, com.github.javaparser.resolution.TypeSolver typeSolver)
    See JLS 15.27.3.
    static boolean
    isCompatibleInALooseInvocationContext(com.github.javaparser.resolution.types.ResolvedType s, com.github.javaparser.resolution.types.ResolvedType t)
    see https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.3
    static boolean
    isCompatibleInALooseInvocationContext(com.github.javaparser.resolution.TypeSolver typeSolver, com.github.javaparser.ast.expr.Expression expression, com.github.javaparser.resolution.types.ResolvedType t)
    see https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.3
    static boolean
    isCompatibleInAStrictInvocationContext(com.github.javaparser.ast.expr.Expression expression, com.github.javaparser.resolution.types.ResolvedType t)
    see https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.3
    static boolean
    isProperType(com.github.javaparser.resolution.types.ResolvedType type)
    The term proper type excludes such "types" that mention inference variables.
    static com.github.javaparser.resolution.types.ResolvedType
    leastUpperBound(Set<com.github.javaparser.resolution.types.ResolvedType> types)
    See JLS 4.10.4.
    static com.github.javaparser.resolution.types.ResolvedType
    toBoxedType(com.github.javaparser.resolution.types.ResolvedPrimitiveType primitiveType)
     
    static com.github.javaparser.resolution.types.ResolvedType
    toBoxedType(com.github.javaparser.resolution.types.ResolvedPrimitiveType primitiveType, com.github.javaparser.resolution.TypeSolver typeSolver)
     
    usedInferenceVariables(com.github.javaparser.resolution.types.ResolvedType type)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TypeHelper

      public TypeHelper()
  • Method Details

    • isProperType

      public static boolean isProperType(com.github.javaparser.resolution.types.ResolvedType type)
      The term proper type excludes such "types" that mention inference variables.
    • isCompatibleInAStrictInvocationContext

      public static boolean isCompatibleInAStrictInvocationContext(com.github.javaparser.ast.expr.Expression expression, com.github.javaparser.resolution.types.ResolvedType t)
      see https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.3
      Parameters:
      expression -
      t -
      Returns:
    • isCompatibleInALooseInvocationContext

      public static boolean isCompatibleInALooseInvocationContext(com.github.javaparser.resolution.TypeSolver typeSolver, com.github.javaparser.ast.expr.Expression expression, com.github.javaparser.resolution.types.ResolvedType t)
      see https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.3
      Parameters:
      expression -
      t -
      Returns:
    • isCompatibleInALooseInvocationContext

      public static boolean isCompatibleInALooseInvocationContext(com.github.javaparser.resolution.types.ResolvedType s, com.github.javaparser.resolution.types.ResolvedType t)
      see https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.3
      Parameters:
      s -
      t -
      Returns:
    • toBoxedType

      public static com.github.javaparser.resolution.types.ResolvedType toBoxedType(com.github.javaparser.resolution.types.ResolvedPrimitiveType primitiveType)
    • toBoxedType

      public static com.github.javaparser.resolution.types.ResolvedType toBoxedType(com.github.javaparser.resolution.types.ResolvedPrimitiveType primitiveType, com.github.javaparser.resolution.TypeSolver typeSolver)
    • areCompatibleThroughWideningReferenceConversion

      public static boolean areCompatibleThroughWideningReferenceConversion(com.github.javaparser.resolution.types.ResolvedType s, com.github.javaparser.resolution.types.ResolvedType t)
    • areCompatibleThroughWideningPrimitiveConversion

      public static boolean areCompatibleThroughWideningPrimitiveConversion(com.github.javaparser.resolution.types.ResolvedType s, com.github.javaparser.resolution.types.ResolvedType t)
    • usedInferenceVariables

      public static Set<InferenceVariable> usedInferenceVariables(com.github.javaparser.resolution.types.ResolvedType type)
    • leastUpperBound

      public static com.github.javaparser.resolution.types.ResolvedType leastUpperBound(Set<com.github.javaparser.resolution.types.ResolvedType> types)
      See JLS 4.10.4. Least Upper Bound. The least upper bound, or "lub", of a set of reference types is a shared supertype that is more specific than any other shared supertype (that is, no other shared supertype is a subtype of the least upper bound).
    • groundTargetTypeOfLambda

      public static com.github.javaparser.utils.Pair<com.github.javaparser.resolution.types.ResolvedType, Boolean> groundTargetTypeOfLambda(com.github.javaparser.ast.expr.LambdaExpr lambdaExpr, com.github.javaparser.resolution.types.ResolvedType T, com.github.javaparser.resolution.TypeSolver typeSolver)
      See JLS 15.27.3. Type of a Lambda Expression
      Returns:
    • getFunctionType

      public static MethodType getFunctionType(com.github.javaparser.resolution.types.ResolvedType type)
    • glb

      public static com.github.javaparser.resolution.types.ResolvedType glb(Set<com.github.javaparser.resolution.types.ResolvedType> types)
      See JLS 5.1.10. Capture Conversion.