org.jetbrains.kotlin.types
Class CastDiagnosticsUtil
java.lang.Object
org.jetbrains.kotlin.types.CastDiagnosticsUtil
public class CastDiagnosticsUtil
- extends java.lang.Object
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 '*'