[FIR2IR] Properly insert casts for smartcasts in argument position

Previously cast inserter didn't consider expected type for arguments
  of function calls

^KT-63257 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-11-07 17:41:22 +02:00
committed by Space Team
parent c70a6425f5
commit 8578a0bf6a
30 changed files with 292 additions and 33 deletions
@@ -1,7 +1,7 @@
fun test1(a: Function0<Unit>) {
when {
a is Runnable -> { // BLOCK
runStatic(r = a)
runStatic(r = a /*as Runnable */)
}
}
}
@@ -9,7 +9,7 @@ fun test1(a: Function0<Unit>) {
fun test2(a: Function0<Unit>) {
when {
a is Runnable -> { // BLOCK
J().run1(r = a)
J().run1(r = a /*as Runnable */)
}
}
}
@@ -17,7 +17,7 @@ fun test2(a: Function0<Unit>) {
fun test3(a: Function0<Unit>) {
when {
a is Runnable -> { // BLOCK
J().run2(r1 = a, r2 = a)
J().run2(r1 = a /*as Runnable */, r2 = a /*as Runnable */)
}
}
}
@@ -25,7 +25,7 @@ fun test3(a: Function0<Unit>) {
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
when {
a is Runnable -> { // BLOCK
J().run2(r1 = a, r2 = b /*-> @FlexibleNullability Runnable? */)
J().run2(r1 = a /*as Runnable */, r2 = b /*-> @FlexibleNullability Runnable? */)
}
}
}
@@ -42,7 +42,7 @@ fun test5x(a: Any) {
when {
a is Runnable -> { // BLOCK
a /*as Runnable */ as Function0<Unit> /*~> Unit */
J().run1(r = a)
J().run1(r = a /*as Runnable */)
}
}
}