diff --git a/proposals/bound-callable-references.md b/proposals/bound-callable-references.md index 9391e4ce8..7e2a14897 100644 --- a/proposals/bound-callable-references.md +++ b/proposals/bound-callable-references.md @@ -162,12 +162,25 @@ fun test() { } ``` -Once the LHS is type-checked and its type is determined to be `T`, the type of the whole class literal expression is `kotlin.reflect.KClass` where `T'` is a type obtained by _substituting `T`'s arguments with star projections (`*`)_. Example: +Once the LHS is type-checked and its type is determined to be `T`, the type of the whole class literal expression is `KClass`, where `erase(T)` represents the most accurate possible type-safe representation of the type `T` and is obtained by substituting `T`'s arguments with star projections (`*`), except when the type is an array. + +More formally, let `T` = `C`, where `C` is a class and `N`, the number of type arguments, might be zero. `erase(T)` is then defined as follows: +- if `C` = `kotlin.Array`: + - if `A1` = `*`, `erase(T)` = `kotlin.Array<*>` + - otherwise `erase(T)` = `kotlin.Array` + - TODO: consider type projections here (`Array`) +- otherwise `erase(T)` = `C<*, ..., *>` + +Examples: ``` fun test() { - "a"::class // KClass - listOf("a")::class // KClass> (not "KClass>"!) - mapOf("a" to 42)::class // KClass> + "a"::class // KClass + listOf("a")::class // KClass> (not "KClass>"!) + listOf(listOf("a"))::class // KClass> (not "KClass>>"!) + mapOf("a" to 42)::class // KClass> + arrayOf("a")::class // KClass> + arrayOf(arrayOf("a"))::class // KClass>> + arrayOf(listOf("a"))::class // KClass>> } ```