[FIR2IR] Don't insert not-needed upcasts for smartcasted expressions

Related to KT-63257
This commit is contained in:
Dmitriy Novozhilov
2023-11-09 10:51:17 +02:00
committed by Space Team
parent aa1a997f8a
commit c70a6425f5
18 changed files with 55 additions and 62 deletions
@@ -20,20 +20,20 @@ fun <T> test0(a: T) where T : KRunnable, T : Function0<Unit> {
fun test1(a: Function0<Unit>) {
when {
a is KRunnable -> { // BLOCK
run1(r = a /*as Any */)
run1(r = a)
}
}
}
fun test2(a: KRunnable) {
a as Function0<Unit> /*~> Unit */
run1(r = a /*as Any */)
run1(r = a)
}
fun test3(a: Function0<Unit>) {
when {
a is KRunnable -> { // BLOCK
run2(r1 = a /*as Any */, r2 = a /*as Any */)
run2(r1 = a, r2 = a)
}
}
}
@@ -41,7 +41,7 @@ fun test3(a: Function0<Unit>) {
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
when {
a is KRunnable -> { // BLOCK
run2(r1 = a /*as Any */, r2 = b /*-> KRunnable */)
run2(r1 = a, r2 = b /*-> KRunnable */)
}
}
}
@@ -70,12 +70,12 @@ fun test6(a: Any) {
fun test7(a: Function1<Int, Int>) {
a as Function0<Unit> /*~> Unit */
run1(r = a /*as Function<Any> */ /*-> KRunnable */)
run1(r = a /*-> KRunnable */)
}
fun <T : Function1<Int, Int>> test7a(a: T) {
a as Function0<Unit> /*~> Unit */
run1(r = a /*as Function<Any> */ /*-> KRunnable */)
run1(r = a /*-> KRunnable */)
}
fun <T> test7b(a: T) where T : Function1<Int, Unit>, T : Function0<Unit> {