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 KotlinType CANT_INFER_FUNCTION_PARAM_TYPE
           
static KotlinType DONT_CARE
           
static KotlinType NO_EXPECTED_TYPE
           
static KotlinType UNIT_EXPECTED_TYPE
           
 
Constructor Summary
TypeUtils()
           
 
Method Summary
static boolean acceptsNullable(KotlinType 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(KotlinTypeChecker typeChecker, KotlinType type)
           
static boolean containsSpecialType(KotlinType type, kotlin.jvm.functions.Function1<KotlinType,java.lang.Boolean> isSpecialType)
           
static boolean containsSpecialType(KotlinType type, KotlinType specialType)
           
static boolean dependsOnTypeConstructors(KotlinType type, java.util.Collection<TypeConstructor> typeParameterConstructors)
           
static boolean dependsOnTypeParameters(KotlinType type, java.util.Collection<TypeParameterDescriptor> typeParameters)
           
static boolean equalTypes(KotlinType a, KotlinType b)
           
static java.util.Set<KotlinType> getAllSupertypes(KotlinType type)
           
static ClassDescriptor getClassDescriptor(KotlinType type)
           
static KotlinType getDefaultPrimitiveNumberType(IntegerValueTypeConstructor numberValueTypeConstructor)
           
static java.util.List<TypeProjection> getDefaultTypeProjections(java.util.List<TypeParameterDescriptor> parameters)
           
static java.util.List<KotlinType> getImmediateSupertypes(KotlinType type)
           
static KotlinType getPrimitiveNumberType(IntegerValueTypeConstructor numberValueTypeConstructor, KotlinType expectedType)
           
static TypeParameterDescriptor getTypeParameterDescriptorOrNull(KotlinType type)
           
static boolean hasNullableLowerBound(TypeParameterDescriptor typeParameterDescriptor)
           
static boolean hasNullableSuperType(KotlinType type)
           
static boolean isDontCarePlaceholder(KotlinType type)
           
static boolean isNonReifiedTypeParemeter(KotlinType type)
           
static boolean isNullableType(KotlinType 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(KotlinType type)
           
static KotlinType makeNotNullable(KotlinType type)
           
static KotlinType makeNullable(KotlinType type)
           
static KotlinType makeNullableAsSpecified(KotlinType type, boolean nullable)
           
static KotlinType makeNullableIfNeeded(KotlinType type, boolean nullable)
           
static TypeProjection makeStarProjection(TypeParameterDescriptor parameterDescriptor)
           
static KotlinType makeUnsubstitutedType(ClassDescriptor classDescriptor, MemberScope unsubstitutedMemberScope)
           
static boolean noExpectedType(KotlinType type)
           
static KotlinType substituteParameters(ClassDescriptor clazz, java.util.List<KotlinType> typeArguments)
           
static KotlinType substituteProjectionsForParameters(ClassDescriptor clazz, java.util.List<TypeProjection> projections)
           
 
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 KotlinType DONT_CARE

CANT_INFER_FUNCTION_PARAM_TYPE

public static final KotlinType CANT_INFER_FUNCTION_PARAM_TYPE

NO_EXPECTED_TYPE

@NotNull
public static final KotlinType NO_EXPECTED_TYPE

UNIT_EXPECTED_TYPE

public static final KotlinType UNIT_EXPECTED_TYPE
Constructor Detail

TypeUtils

public TypeUtils()
Method Detail

noExpectedType

public static boolean noExpectedType(@NotNull
                                     KotlinType type)

isDontCarePlaceholder

public static boolean isDontCarePlaceholder(@Nullable
                                            KotlinType type)

makeNullable

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

makeNotNullable

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

makeNullableAsSpecified

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

makeNullableIfNeeded

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

canHaveSubtypes

public static boolean canHaveSubtypes(KotlinTypeChecker typeChecker,
                                      @NotNull
                                      KotlinType type)

makeUnsubstitutedType

@NotNull
public static KotlinType makeUnsubstitutedType(ClassDescriptor classDescriptor,
                                                       MemberScope unsubstitutedMemberScope)

getDefaultTypeProjections

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

getImmediateSupertypes

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

getAllSupertypes

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

hasNullableLowerBound

public static boolean hasNullableLowerBound(@NotNull
                                            TypeParameterDescriptor typeParameterDescriptor)

isNullableType

public static boolean isNullableType(@NotNull
                                     KotlinType 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
                                      KotlinType 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
                                           KotlinType type)

getClassDescriptor

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

substituteParameters

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

substituteProjectionsForParameters

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

equalTypes

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

dependsOnTypeParameters

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

dependsOnTypeConstructors

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

containsSpecialType

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

containsSpecialType

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

makeStarProjection

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

getDefaultPrimitiveNumberType

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

getPrimitiveNumberType

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

isTypeParameter

public static boolean isTypeParameter(@NotNull
                                      KotlinType type)

isNonReifiedTypeParemeter

public static boolean isNonReifiedTypeParemeter(@NotNull
                                                KotlinType type)

getTypeParameterDescriptorOrNull

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