Context
Kotlin's kotlin.String
type is currently defined as follows (1.1.2):
public class String : Comparable<String>, CharSequence {
companion object {}
// Operator and override function definitions.
}
Some extensions defined on kotlin.String
cast the receiving instance to the java.lang.String
type to forward method invocations. For example (1.1.2):
@kotlin.internal.InlineOnly
public inline fun String.toLowerCase(): String = (this as java.lang.String).toLowerCase()
However, nothing in the kotlin.String
type definition makes it clear to me that this cast is guaranteed to succeed.
Questions
- Is there any way to easily determine if any given Kotlin type is mapped to a corresponding Java type in this manner?
- Where does this conversion actually happen? (Looking for a link to the relevant source code if possible.)