org.jetbrains.kotlin.types
Class TypeUtils

java.lang.Object
  extended by org.jetbrains.kotlin.types.TypeUtils

public class TypeUtils
extends java.lang.Object


Nested Class Summary
static class TypeUtils.SpecialType
           
 
Field Summary
static JetType CANT_INFER_FUNCTION_PARAM_TYPE
           
static JetType DONT_CARE
           
static JetType NO_EXPECTED_TYPE
           
static JetType PLACEHOLDER_FUNCTION_TYPE
           
static JetType UNIT_EXPECTED_TYPE
           
 
Constructor Summary
TypeUtils()
           
 
Method Summary
static boolean acceptsNullable(JetType type)
          Differs from `isNullableType` only by treating type parameters: acceptsNullable(T) <=> T has nullable lower bound Semantics should be the same as `isSubtype(Nothing?, T)`
static boolean canHaveSubtypes(JetTypeChecker typeChecker, JetType type)
           
static JetType commonSupertypeForNumberTypes(java.util.Collection<JetType> numberLowerBounds)
           
static boolean containsSpecialType(JetType type, kotlin.jvm.functions.Function1<JetType,java.lang.Boolean> isSpecialType)
           
static boolean containsSpecialType(JetType type, JetType specialType)
           
static boolean dependsOnTypeConstructors(JetType type, java.util.Collection<TypeConstructor> typeParameterConstructors)
           
static boolean dependsOnTypeParameters(JetType type, java.util.Collection<TypeParameterDescriptor> typeParameters)
           
static boolean equalTypes(JetType a, JetType b)
           
static java.util.Set<JetType> getAllSupertypes(JetType type)
           
static ClassDescriptor getClassDescriptor(JetType type)
           
static JetType getDefaultPrimitiveNumberType(IntegerValueTypeConstructor numberValueTypeConstructor)
           
static java.util.List<TypeProjection> getDefaultTypeProjections(java.util.List<TypeParameterDescriptor> parameters)
           
static java.util.List<JetType> getImmediateSupertypes(JetType type)
           
static JetType getPrimitiveNumberType(IntegerValueTypeConstructor numberValueTypeConstructor, JetType expectedType)
           
static TypeParameterDescriptor getTypeParameterDescriptorOrNull(JetType type)
           
static boolean hasNullableLowerBound(TypeParameterDescriptor typeParameterDescriptor)
           
static boolean hasNullableSuperType(JetType type)
           
static boolean isDontCarePlaceholder(JetType type)
           
static boolean isNonReifiedTypeParemeter(JetType type)
           
static boolean isNullableType(JetType type)
          A work-around of the generic nullability problem in the type checker Semantics should be the same as `!isSubtype(T, Any)`
static boolean isTypeParameter(JetType type)
           
static TypeSubstitutor makeConstantSubstitutor(java.util.Collection<TypeParameterDescriptor> typeParameterDescriptors, JetType type)
           
static JetType makeNotNullable(JetType type)
           
static JetType makeNullable(JetType type)
           
static JetType makeNullableAsSpecified(JetType type, boolean nullable)
           
static JetType makeNullableIfNeeded(JetType type, boolean nullable)
           
static TypeProjection makeStarProjection(TypeParameterDescriptor parameterDescriptor)
           
static JetType makeUnsubstitutedType(ClassDescriptor classDescriptor, JetScope unsubstitutedMemberScope)
           
static boolean noExpectedType(JetType type)
           
static JetType substituteParameters(ClassDescriptor clazz, java.util.List<JetType> typeArguments)
           
static JetType substituteProjectionsForParameters(ClassDescriptor clazz, java.util.List<TypeProjection> projections)
           
static java.util.List<TypeConstructor> topologicallySortSuperclassesAndRecordAllInstances(JetType type, java.util.Map<TypeConstructor,java.util.Set<JetType>> constructorToAllInstances, java.util.Set<TypeConstructor> visited)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DONT_CARE

public static final JetType DONT_CARE

PLACEHOLDER_FUNCTION_TYPE

public static final JetType PLACEHOLDER_FUNCTION_TYPE

CANT_INFER_FUNCTION_PARAM_TYPE

public static final JetType CANT_INFER_FUNCTION_PARAM_TYPE

NO_EXPECTED_TYPE

public static final JetType NO_EXPECTED_TYPE

UNIT_EXPECTED_TYPE

public static final JetType UNIT_EXPECTED_TYPE
Constructor Detail

TypeUtils

public TypeUtils()
Method Detail

noExpectedType

public static boolean noExpectedType(@NotNull
                                     JetType type)

isDontCarePlaceholder

public static boolean isDontCarePlaceholder(@Nullable
                                            JetType type)

makeNullable

@NotNull
public static JetType makeNullable(@NotNull
                                           JetType type)

makeNotNullable

@NotNull
public static JetType makeNotNullable(@NotNull
                                              JetType type)

makeNullableAsSpecified

@NotNull
public static JetType makeNullableAsSpecified(@NotNull
                                                      JetType type,
                                                      boolean nullable)

makeNullableIfNeeded

@NotNull
public static JetType makeNullableIfNeeded(@NotNull
                                                   JetType type,
                                                   boolean nullable)

canHaveSubtypes

public static boolean canHaveSubtypes(JetTypeChecker typeChecker,
                                      @NotNull
                                      JetType type)

makeUnsubstitutedType

@NotNull
public static JetType makeUnsubstitutedType(ClassDescriptor classDescriptor,
                                                    JetScope unsubstitutedMemberScope)

getDefaultTypeProjections

@NotNull
public static java.util.List<TypeProjection> getDefaultTypeProjections(@NotNull
                                                                               java.util.List<TypeParameterDescriptor> parameters)

getImmediateSupertypes

@NotNull
public static java.util.List<JetType> getImmediateSupertypes(@NotNull
                                                                     JetType type)

getAllSupertypes

@NotNull
public static java.util.Set<JetType> getAllSupertypes(@NotNull
                                                              JetType type)

hasNullableLowerBound

public static boolean hasNullableLowerBound(@NotNull
                                            TypeParameterDescriptor typeParameterDescriptor)

isNullableType

public static boolean isNullableType(@NotNull
                                     JetType type)
A work-around of the generic nullability problem in the type checker Semantics should be the same as `!isSubtype(T, Any)`

Returns:
true if a value of this type can be null

acceptsNullable

public static boolean acceptsNullable(@NotNull
                                      JetType type)
Differs from `isNullableType` only by treating type parameters: acceptsNullable(T) <=> T has nullable lower bound Semantics should be the same as `isSubtype(Nothing?, T)`

Returns:
true if `null` can be assigned to storage of this type

hasNullableSuperType

public static boolean hasNullableSuperType(@NotNull
                                           JetType type)

getClassDescriptor

@Nullable
public static ClassDescriptor getClassDescriptor(@NotNull
                                                          JetType type)

substituteParameters

@NotNull
public static JetType substituteParameters(@NotNull
                                                   ClassDescriptor clazz,
                                                   @NotNull
                                                   java.util.List<JetType> typeArguments)

substituteProjectionsForParameters

@NotNull
public static JetType substituteProjectionsForParameters(@NotNull
                                                                 ClassDescriptor clazz,
                                                                 @NotNull
                                                                 java.util.List<TypeProjection> projections)

equalTypes

public static boolean equalTypes(@NotNull
                                 JetType a,
                                 @NotNull
                                 JetType b)

dependsOnTypeParameters

public static boolean dependsOnTypeParameters(@NotNull
                                              JetType type,
                                              @NotNull
                                              java.util.Collection<TypeParameterDescriptor> typeParameters)

dependsOnTypeConstructors

public static boolean dependsOnTypeConstructors(@NotNull
                                                JetType type,
                                                @NotNull
                                                java.util.Collection<TypeConstructor> typeParameterConstructors)

containsSpecialType

public static boolean containsSpecialType(@Nullable
                                          JetType type,
                                          @NotNull
                                          JetType specialType)

containsSpecialType

public static boolean containsSpecialType(@Nullable
                                          JetType type,
                                          @NotNull
                                          kotlin.jvm.functions.Function1<JetType,java.lang.Boolean> isSpecialType)

makeStarProjection

@NotNull
public static TypeProjection makeStarProjection(@NotNull
                                                        TypeParameterDescriptor parameterDescriptor)

commonSupertypeForNumberTypes

@Nullable
public static JetType commonSupertypeForNumberTypes(@NotNull
                                                             java.util.Collection<JetType> numberLowerBounds)

getDefaultPrimitiveNumberType

@NotNull
public static JetType getDefaultPrimitiveNumberType(@NotNull
                                                            IntegerValueTypeConstructor numberValueTypeConstructor)

getPrimitiveNumberType

@NotNull
public static JetType getPrimitiveNumberType(@NotNull
                                                     IntegerValueTypeConstructor numberValueTypeConstructor,
                                                     @NotNull
                                                     JetType expectedType)

topologicallySortSuperclassesAndRecordAllInstances

public static java.util.List<TypeConstructor> topologicallySortSuperclassesAndRecordAllInstances(@NotNull
                                                                                                 JetType type,
                                                                                                 @NotNull
                                                                                                 java.util.Map<TypeConstructor,java.util.Set<JetType>> constructorToAllInstances,
                                                                                                 @NotNull
                                                                                                 java.util.Set<TypeConstructor> visited)

makeConstantSubstitutor

public static TypeSubstitutor makeConstantSubstitutor(java.util.Collection<TypeParameterDescriptor> typeParameterDescriptors,
                                                      JetType type)

isTypeParameter

public static boolean isTypeParameter(@NotNull
                                      JetType type)

isNonReifiedTypeParemeter

public static boolean isNonReifiedTypeParemeter(@NotNull
                                                JetType type)

getTypeParameterDescriptorOrNull

@Nullable
public static TypeParameterDescriptor getTypeParameterDescriptorOrNull(@NotNull
                                                                                JetType type)