[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:
committed by
Space Team
parent
c70a6425f5
commit
8578a0bf6a
Vendored
+10
-5
@@ -44,7 +44,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
r: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
r: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
FUN name:test2 visibility:public modality:FINAL <> (a:<root>.KRunnable) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:<root>.KRunnable
|
||||
BLOCK_BODY
|
||||
@@ -62,8 +63,10 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
CALL 'public final fun run2 (r1: <root>.KRunnable, r2: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
r1: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
r2: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
r1: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
r2: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>, b:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Function0<kotlin.Unit>
|
||||
@@ -74,7 +77,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
CALL 'public final fun run2 (r1: <root>.KRunnable, r2: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
r1: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
r1: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
r2: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
||||
GET_VAR 'b: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||
@@ -101,7 +105,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
||||
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
r: GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
||||
r: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
||||
FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
|
||||
Vendored
+4
-4
@@ -20,7 +20,7 @@ fun <T> test0(a: T) where T : KRunnable, T : Function0<Unit> {
|
||||
fun test1(a: Function0<Unit>) {
|
||||
when {
|
||||
a is KRunnable -> { // BLOCK
|
||||
run1(r = a)
|
||||
run1(r = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ fun test2(a: KRunnable) {
|
||||
fun test3(a: Function0<Unit>) {
|
||||
when {
|
||||
a is KRunnable -> { // BLOCK
|
||||
run2(r1 = a, r2 = a)
|
||||
run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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, r2 = b /*-> KRunnable */)
|
||||
run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ fun test5x(a: Any) {
|
||||
when {
|
||||
a is KRunnable -> { // BLOCK
|
||||
a /*as KRunnable */ as Function0<Unit> /*~> Unit */
|
||||
run1(r = a)
|
||||
run1(r = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user