[FIR2IR] Don't insert not-needed upcasts for smartcasted expressions
Related to KT-63257
This commit is contained in:
committed by
Space Team
parent
aa1a997f8a
commit
c70a6425f5
Vendored
+7
-14
@@ -44,8 +44,7 @@ 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: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
r: 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
|
||||
@@ -53,8 +52,7 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
|
||||
GET_VAR 'a: <root>.KRunnable declared in <root>.test2' type=<root>.KRunnable origin=null
|
||||
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
r: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any
|
||||
GET_VAR 'a: <root>.KRunnable declared in <root>.test2' type=<root>.KRunnable origin=null
|
||||
r: GET_VAR 'a: <root>.KRunnable declared in <root>.test2' type=<root>.KRunnable origin=null
|
||||
FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
@@ -64,10 +62,8 @@ 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: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
r2: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<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
|
||||
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>
|
||||
@@ -78,8 +74,7 @@ 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: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
r1: 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
|
||||
@@ -125,8 +120,7 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
GET_VAR 'a: kotlin.Function1<kotlin.Int, kotlin.Int> declared in <root>.test7' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=null
|
||||
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
r: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
||||
TYPE_OP type=kotlin.Function<kotlin.Any> origin=IMPLICIT_CAST typeOperand=kotlin.Function<kotlin.Any>
|
||||
GET_VAR 'a: kotlin.Function1<kotlin.Int, kotlin.Int> declared in <root>.test7' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=null
|
||||
GET_VAR 'a: kotlin.Function1<kotlin.Int, kotlin.Int> declared in <root>.test7' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=null
|
||||
FUN name:test7a visibility:public modality:FINAL <T> (a:T of <root>.test7a) returnType:kotlin.Unit
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Function1<kotlin.Int, kotlin.Int>] reified:false
|
||||
VALUE_PARAMETER name:a index:0 type:T of <root>.test7a
|
||||
@@ -136,8 +130,7 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
GET_VAR 'a: T of <root>.test7a declared in <root>.test7a' type=T of <root>.test7a origin=null
|
||||
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
r: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
||||
TYPE_OP type=kotlin.Function<kotlin.Any> origin=IMPLICIT_CAST typeOperand=kotlin.Function<kotlin.Any>
|
||||
GET_VAR 'a: T of <root>.test7a declared in <root>.test7a' type=T of <root>.test7a origin=null
|
||||
GET_VAR 'a: T of <root>.test7a declared in <root>.test7a' type=T of <root>.test7a origin=null
|
||||
FUN name:test7b visibility:public modality:FINAL <T> (a:T of <root>.test7b) returnType:kotlin.Unit
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Function1<kotlin.Int, kotlin.Unit>; kotlin.Function0<kotlin.Unit>] reified:false
|
||||
VALUE_PARAMETER name:a index:0 type:T of <root>.test7b
|
||||
|
||||
Vendored
+6
-6
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user