Report error on typeOf<suspend ...>()

Otherwise an invalid type is constructed which causes kotlin-reflect to
crash, and stdlib implementation to render the type incorrectly. The
reason is that suspend functional types are not properly supported in
reflection. Once they are supported, this error can be removed.

 #KT-47562
This commit is contained in:
Alexander Udalov
2021-07-06 16:10:01 +02:00
parent 68432f0c20
commit 438ce57183
14 changed files with 90 additions and 8 deletions
@@ -0,0 +1,12 @@
// WITH_RUNTIME
// USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
import kotlin.reflect.*
inline fun <reified X> f() = g<List<X>>()
inline fun <reified Y> g() = typeOf<Y>()
fun test() {
<!TYPEOF_SUSPEND_TYPE!>typeOf<suspend () -> Int>()<!>
<!TYPEOF_SUSPEND_TYPE!>f<suspend (String) -> Unit>()<!>
}
@@ -0,0 +1,5 @@
package
public inline fun </*0*/ reified X> f(): kotlin.reflect.KType
public inline fun </*0*/ reified Y> g(): kotlin.reflect.KType
public fun test(): kotlin.Unit