[IR] Add tests for KT-47342
This commit is contained in:
committed by
teamcityserver
parent
dbd28142d0
commit
882016c22f
@@ -0,0 +1,72 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
open class B<T>
|
||||
|
||||
open class BB<T>
|
||||
|
||||
interface I<T>
|
||||
interface II<T> {
|
||||
fun bar(): String = "OK"
|
||||
}
|
||||
|
||||
class CC : I<CC>
|
||||
|
||||
inline fun <T : I<T>> test0(a: Any): String = (a as? T != null).toString()[0].toString()
|
||||
|
||||
class CCC : I<CCC>, II<CCC>, B<CCC>()
|
||||
|
||||
inline fun <T> test1(a: Any): String where
|
||||
T : I<T>,
|
||||
T : II<T>,
|
||||
T : B<T> {
|
||||
return (a as? T != null).toString()[1].toString()
|
||||
}
|
||||
|
||||
class CCCC : I<CCCC>, II<CCCC>
|
||||
|
||||
inline fun <T> test2(a: Any): String where
|
||||
T : I<T>,
|
||||
T : II<T> {
|
||||
return (a as? T != null).toString()[2].toString()
|
||||
}
|
||||
|
||||
open class BX<T1, T2>
|
||||
class CI : I<CI>
|
||||
class DB : BX<DB, CI>()
|
||||
class CIB : BX<CIB, CI>(), I<CIB>
|
||||
|
||||
inline fun <TI: I<TI>, TC : BX<TC, TI>> test3(a: Any): String {
|
||||
val s1 = (a as? TC != null).toString()[3].toString()
|
||||
val s2 = (a as? TI != null).toString()[3].toString()
|
||||
return return s1 + s2
|
||||
}
|
||||
|
||||
// KT-47342
|
||||
|
||||
object O : II<I<Any>>
|
||||
|
||||
inline fun <T : I<T>> testKt(): II<T> = O as II<T>
|
||||
|
||||
fun foo(a: Any): String = a.toString()
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
|
||||
result += foo(test0<CC>(Any()))
|
||||
result += foo(test0<CC>(CC()))
|
||||
|
||||
result += foo(test1<CCC>(Any()))
|
||||
result += foo(test1<CCC>(CCC()))
|
||||
|
||||
result += foo(test2<CCCC>(Any()))
|
||||
result += foo(test2<CCCC>(CCCC()))
|
||||
|
||||
result += foo(test3<CI, DB>(Any()))
|
||||
result += foo(test3<CI, DB>(CI()))
|
||||
result += foo(test3<CI, DB>(DB()))
|
||||
result += foo(test3<CI, DB>(CIB()))
|
||||
|
||||
if (result != "ftarlussseesee") return "FAIL: $result"
|
||||
|
||||
return foo(testKt<CC>().bar())
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
interface A<T1, T2>
|
||||
interface B<T>
|
||||
interface C<T>
|
||||
|
||||
class C1 : A<B<Any>, C<Any>>, B<Any>, C<Any>
|
||||
|
||||
class CT1 : A<B<Any>, C<Any>>
|
||||
class CK1 : B<Any>
|
||||
class CL1 : C<Any>
|
||||
class CTK1 : A<B<Any>, C<Any>>, B<Any>
|
||||
class CTL1 : A<B<Any>, C<Any>>, C<Any>
|
||||
class CKL1 : B<Any>, C<Any>
|
||||
class CTKL1 : A<B<Any>, C<Any>>, B<Any>, C<Any>
|
||||
|
||||
inline fun <Q: Any, T: A<K, L>, K: B<Q>, L: C<Q>> test1(a: Any): String {
|
||||
val s1 = (a as? T != null).toString()[1].toString()
|
||||
val s2 = (a as? K != null).toString()[1].toString()
|
||||
val s3 = (a as? L != null).toString()[1].toString()
|
||||
return s1 + s2 + s3
|
||||
}
|
||||
|
||||
class C2 : A<C2, C2>, B<C2>, C<C2>
|
||||
|
||||
class CT2 : A<B<CT2>, C<CT2>>
|
||||
class CK2 : B<CK2>
|
||||
class CL2 : C<CL2>
|
||||
class CTK2 : A<B<CTK2>, C<CTK2>>, B<CTK2>
|
||||
class CTL2 : A<B<CTL2>, C<CTL2>>, C<CTL2>
|
||||
class CKL2 : B<CKL2>, C<CKL2>
|
||||
class CTKL2 : A<B<CTKL2>, C<CTKL2>>, B<CTKL2>, C<CTKL2>
|
||||
|
||||
inline fun <T: A<K, L>, K: B<T>, L: C<T>> test2(a: Any): String {
|
||||
val s1 = (a as? T != null).toString()[2].toString()
|
||||
val s2 = (a as? K != null).toString()[2].toString()
|
||||
val s3 = (a as? L != null).toString()[2].toString()
|
||||
return s1 + s2 + s3
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
|
||||
result += test1<Any, C1, B<Any>, C<Any>>(Any())
|
||||
result += test1<Any, C1, B<Any>, C<Any>>(CT1())
|
||||
result += test1<Any, C1, B<Any>, C<Any>>(CK1())
|
||||
result += test1<Any, C1, B<Any>, C<Any>>(CL1())
|
||||
result += test1<Any, C1, B<Any>, C<Any>>(CTK1())
|
||||
result += test1<Any, C1, B<Any>, C<Any>>(CTL1())
|
||||
result += test1<Any, C1, B<Any>, C<Any>>(CKL1())
|
||||
result += test1<Any, C1, B<Any>, C<Any>>(CTKL1())
|
||||
|
||||
if (result != "aaaraaaraaarrrarararrrrr") return "FAIL1: $result"
|
||||
result = ""
|
||||
|
||||
result += test2<C2, C2, C2>(Any())
|
||||
result += test2<C2, C2, C2>(CT2())
|
||||
result += test2<C2, C2, C2>(CK2())
|
||||
result += test2<C2, C2, C2>(CL2())
|
||||
result += test2<C2, C2, C2>(CTK2())
|
||||
result += test2<C2, C2, C2>(CTL2())
|
||||
result += test2<C2, C2, C2>(CKL2())
|
||||
result += test2<C2, C2, C2>(CTKL2())
|
||||
|
||||
if (result != "lllulllullluuulululuuuuu") return "FAIL2: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user