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 SimpleType CANT_INFER_FUNCTION_PARAM_TYPE
           
static SimpleType DONT_CARE
           
static SimpleType NO_EXPECTED_TYPE
           
static SimpleType 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 contains(KotlinType type, kotlin.jvm.functions.Function1<UnwrappedType,java.lang.Boolean> isSpecialType)
           
static boolean contains(KotlinType type, KotlinType specialType)
           
static KotlinType createSubstitutedSupertype(KotlinType subType, KotlinType superType, TypeSubstitutor substitutor)
           
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(java.util.Collection<KotlinType> supertypes)
           
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 hasNullableSuperType(KotlinType type)
           
static boolean isDontCarePlaceholder(KotlinType type)
           
static boolean isNonReifiedTypeParameter(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 isReifiedTypeParameter(KotlinType type)
           
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 SimpleType makeNullableIfNeeded(SimpleType type, boolean nullable)
           
static TypeProjection makeStarProjection(TypeParameterDescriptor parameterDescriptor)
           
static SimpleType makeUnsubstitutedType(ClassifierDescriptor classifierDescriptor, 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 SimpleType DONT_CARE

CANT_INFER_FUNCTION_PARAM_TYPE

public static final SimpleType CANT_INFER_FUNCTION_PARAM_TYPE

NO_EXPECTED_TYPE

@NotNull
public static final SimpleType NO_EXPECTED_TYPE

UNIT_EXPECTED_TYPE

public static final SimpleType 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 SimpleType makeNullableIfNeeded(@NotNull
                                                      SimpleType 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 SimpleType makeUnsubstitutedType(ClassifierDescriptor classifierDescriptor,
                                                       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)

createSubstitutedSupertype

@Nullable
public static KotlinType createSubstitutedSupertype(@NotNull
                                                             KotlinType subType,
                                                             @NotNull
                                                             KotlinType superType,
                                                             @NotNull
                                                             TypeSubstitutor substitutor)

getAllSupertypes

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

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)

contains

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

contains

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

makeStarProjection

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

getDefaultPrimitiveNumberType

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

getDefaultPrimitiveNumberType

@Nullable
public static KotlinType getDefaultPrimitiveNumberType(@NotNull
                                                                java.util.Collection<KotlinType> supertypes)

getPrimitiveNumberType

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

isTypeParameter

public static boolean isTypeParameter(@NotNull
                                      KotlinType type)

isReifiedTypeParameter

public static boolean isReifiedTypeParameter(@NotNull
                                             KotlinType type)

isNonReifiedTypeParameter

public static boolean isNonReifiedTypeParameter(@NotNull
                                                KotlinType type)

getTypeParameterDescriptorOrNull

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