[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
+6
-12
@@ -8,8 +8,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 open fun runStatic (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in <root>.J' 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:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
@@ -20,8 +19,7 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.J' type=<root>.J origin=null
|
||||
r: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test2' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
r: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test2' type=kotlin.Function0<kotlin.Unit> 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
|
||||
@@ -32,10 +30,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
CALL 'public open fun run2 (r1: @[FlexibleNullability] java.lang.Runnable?, r2: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.J' type=<root>.J 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>
|
||||
@@ -47,8 +43,7 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
CALL 'public open fun run2 (r1: @[FlexibleNullability] java.lang.Runnable?, r2: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.J' type=<root>.J 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=@[FlexibleNullability] java.lang.Runnable? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] java.lang.Runnable?
|
||||
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
|
||||
@@ -98,8 +93,7 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.J' type=<root>.J origin=null
|
||||
r: TYPE_OP type=@[FlexibleNullability] java.lang.Runnable? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] java.lang.Runnable?
|
||||
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:test8 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
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
fun test1(a: Function0<Unit>) {
|
||||
when {
|
||||
a is Runnable -> { // BLOCK
|
||||
runStatic(r = a /*as Any */)
|
||||
runStatic(r = a)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ fun test1(a: Function0<Unit>) {
|
||||
fun test2(a: Function0<Unit>) {
|
||||
when {
|
||||
a is Runnable -> { // BLOCK
|
||||
J().run1(r = a /*as Any */)
|
||||
J().run1(r = a)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ fun test2(a: Function0<Unit>) {
|
||||
fun test3(a: Function0<Unit>) {
|
||||
when {
|
||||
a is Runnable -> { // BLOCK
|
||||
J().run2(r1 = a /*as Any */, r2 = a /*as Any */)
|
||||
J().run2(r1 = a, r2 = a)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 /*as Any */, r2 = b /*-> @FlexibleNullability Runnable? */)
|
||||
J().run2(r1 = a, r2 = b /*-> @FlexibleNullability Runnable? */)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ fun test6(a: Any) {
|
||||
|
||||
fun test7(a: Function1<Int, Int>) {
|
||||
a as Function0<Unit> /*~> Unit */
|
||||
J().run1(r = a /*as Function<Any> */ /*-> @FlexibleNullability Runnable? */)
|
||||
J().run1(r = a /*-> @FlexibleNullability Runnable? */)
|
||||
}
|
||||
|
||||
fun test8(a: Function0<Unit>) {
|
||||
|
||||
Reference in New Issue
Block a user