[FIR2IR] Don't replace while loop and when branch body blocks with single expression. Skip some empty blocks.
https://youtrack.jetbrains.com/issue/KT-60264/K2-while-loop-body-block-sometimes-replaced-with-single-expression Merge-request: KT-MR-12035 Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
f4df4f8007
commit
9a2eff6487
Vendored
-40
@@ -1,40 +0,0 @@
|
||||
FILE fqName:<root> fileName:/samConversionInVarargsMixed.kt
|
||||
CLASS INTERFACE name:MyRunnable modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MyRunnable
|
||||
FUN name:run visibility:public modality:ABSTRACT <> ($this:<root>.MyRunnable) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.MyRunnable
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:test visibility:public modality:FINAL <> (a:kotlin.Any, r:<root>.MyRunnable) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
VALUE_PARAMETER name:r index:1 type:<root>.MyRunnable
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.MyRunnable
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
|
||||
then: CALL 'public final fun foo (vararg rs: <root>.MyRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
rs: VARARG type=kotlin.Array<out <root>.MyRunnable> varargElementType=<root>.MyRunnable
|
||||
TYPE_OP type=<root>.MyRunnable origin=SAM_CONVERSION typeOperand=<root>.MyRunnable
|
||||
FUN_EXPR type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Unit declared in <root>.test'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
GET_VAR 'r: <root>.MyRunnable declared in <root>.test' type=<root>.MyRunnable origin=null
|
||||
TYPE_OP type=<root>.MyRunnable origin=IMPLICIT_CAST typeOperand=<root>.MyRunnable
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
|
||||
FUN name:foo visibility:public modality:FINAL <> (rs:kotlin.Array<out <root>.MyRunnable>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:rs index:0 type:kotlin.Array<out <root>.MyRunnable> varargElementType:<root>.MyRunnable [vararg]
|
||||
BLOCK_BODY
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
fun interface MyRunnable {
|
||||
abstract fun run()
|
||||
|
||||
}
|
||||
|
||||
fun test(a: Any, r: MyRunnable) {
|
||||
when {
|
||||
a is MyRunnable -> foo(rs = [local fun <anonymous>() {
|
||||
return Unit
|
||||
}
|
||||
/*-> MyRunnable */, r, a /*as MyRunnable */])
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(vararg rs: MyRunnable) {
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
fun interface MyRunnable {
|
||||
fun run()
|
||||
}
|
||||
|
||||
Vendored
+20
-16
@@ -42,9 +42,10 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
then: 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=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||
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=<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
|
||||
@@ -61,11 +62,12 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
then: 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=<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
|
||||
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=<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,11 +76,12 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
then: 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=<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
|
||||
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=<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
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
@@ -86,9 +89,10 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any origin=null
|
||||
then: 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=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any 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=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any origin=null
|
||||
FUN name:test5x visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
|
||||
Vendored
+13
-4
@@ -19,7 +19,9 @@ fun <T> test0(a: T) where T : KRunnable, T : Function0<Unit> {
|
||||
|
||||
fun test1(a: Function0<Unit>) {
|
||||
when {
|
||||
a is KRunnable -> run1(r = a /*as KRunnable */)
|
||||
a is KRunnable -> { // BLOCK
|
||||
run1(r = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,19 +32,25 @@ fun test2(a: KRunnable) {
|
||||
|
||||
fun test3(a: Function0<Unit>) {
|
||||
when {
|
||||
a is KRunnable -> run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */)
|
||||
a is KRunnable -> { // BLOCK
|
||||
run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
|
||||
when {
|
||||
a is KRunnable -> run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */)
|
||||
a is KRunnable -> { // BLOCK
|
||||
run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(a: Any) {
|
||||
when {
|
||||
a is KRunnable -> run1(r = a /*as KRunnable */)
|
||||
a is KRunnable -> { // BLOCK
|
||||
run1(r = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,3 +97,4 @@ fun test8(a: Function0<Unit>) {
|
||||
fun test9() {
|
||||
run1(r = ::test9 /*-> KRunnable */)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user