[JS BEs] use star projection when type parameter used recursively

#KT-37128 Fixed
This commit is contained in:
Zalim Bashorov
2020-03-05 13:10:26 +03:00
parent 8c7562d338
commit 7cf8697e30
10 changed files with 127 additions and 39 deletions
@@ -0,0 +1,33 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
// See KT-37128
import kotlin.reflect.typeOf
// TODO check real effects to fix the behavior when we reach consensus
// and to be sure that something is not dropped by optimizations.
@OptIn(kotlin.ExperimentalStdlibApi::class)
inline fun <reified T> T.causeBug() {
val x = this
x is T
x as T
T::class
typeOf<T>()
Array<T>(1) { x }
}
interface SomeToImplement<SELF_TVAR>
class Y : SomeToImplement<Y>
class Something<T> where T: SomeToImplement<T> {
fun op() = causeBug()
}
fun box(): String {
Something<Y>().op()
return "OK"
}