org.jetbrains.kotlin.types
Class CastDiagnosticsUtil

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

public class CastDiagnosticsUtil
extends java.lang.Object


Method Summary
static TypeReconstructionResult findStaticallyKnownSubtype(JetType supertype, TypeConstructor subtypeConstructor)
          Remember that we are trying to cast something of type supertype to subtype.
static boolean isCastErased(JetType supertype, JetType subtype, JetTypeChecker typeChecker)
          Check if cast from supertype to subtype is erased.
static boolean isCastPossible(JetType lhsType, JetType rhsType, PlatformToKotlinClassMap platformToKotlinClassMap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isCastPossible

public static boolean isCastPossible(@NotNull
                                     JetType lhsType,
                                     @NotNull
                                     JetType rhsType,
                                     @NotNull
                                     PlatformToKotlinClassMap platformToKotlinClassMap)

isCastErased

public static boolean isCastErased(@NotNull
                                   JetType supertype,
                                   @NotNull
                                   JetType subtype,
                                   @NotNull
                                   JetTypeChecker typeChecker)
Check if cast from supertype to subtype is erased. It is an error in "is" statement and warning in "as".


findStaticallyKnownSubtype

public static TypeReconstructionResult findStaticallyKnownSubtype(@NotNull
                                                                  JetType supertype,
                                                                  @NotNull
                                                                  TypeConstructor subtypeConstructor)
Remember that we are trying to cast something of type supertype to subtype. Since at runtime we can only check the class (type constructor), the rest of the subtype should be known statically, from supertype. This method reconstructs all static information that can be obtained from supertype. Example 1: supertype = Collection subtype = List<...> result = List, all arguments are inferred Example 2: supertype = Any subtype = List<...> result = List<*>, some arguments were not inferred, replaced with '*'