Class TypeHelper


  • public class TypeHelper
    extends java.lang.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.
    • Constructor Detail

      • TypeHelper

        public TypeHelper()
    • Method Detail

      • isProperType

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

        public static boolean isCompatibleInAStrictInvocationContext​(Expression expression,
                                                                     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​(TypeSolver typeSolver,
                                                                    Expression expression,
                                                                    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​(ResolvedType s,
                                                                    ResolvedType t)
        see https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.3
        Parameters:
        s -
        t -
        Returns:
      • areCompatibleThroughWideningReferenceConversion

        public static boolean areCompatibleThroughWideningReferenceConversion​(ResolvedType s,
                                                                              ResolvedType t)
      • areCompatibleThroughWideningPrimitiveConversion

        public static boolean areCompatibleThroughWideningPrimitiveConversion​(ResolvedType s,
                                                                              ResolvedType t)
      • leastUpperBound

        public static ResolvedType leastUpperBound​(java.util.Set<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).