tryCast

open fun tryCast(type: Type, targetType: Type, hint: HasType? = null, targetHint: HasType? = null): CastResult

This function checks, if type can be cast into targetType. Note, this also takes the WrapState of the type into account, which means that pointer types of derived types will not match with a non-pointer type of its base type. But, if both are pointer types, they will match.

Optionally, the nodes that hold the respective type can be supplied as hint and targetHint.