From dfc86feecd85060e5f5cf7a2173638cbf5d98101 Mon Sep 17 00:00:00 2001 From: Mads Ager Date: Thu, 7 Jan 2021 13:56:02 +0100 Subject: [PATCH] [IR] Extend test coverage for smart cast handling. --- ...ackBoxAgainstJavaCodegenTestGenerated.java | 5 + .../ir/FirBlackBoxCodegenTestGenerated.java | 10 ++ .../kotlin/fir/Fir2IrTextTestGenerated.java | 10 ++ .../codegen/box/ieee754/smartCastToInt.kt | 8 ++ .../box/smartCasts/multipleSmartCast.kt | 22 +++ .../sam/smartCastSamConversion.kt | 22 +++ .../nullableAnyAsIntToDouble.fir.txt | 18 --- .../nullableAnyAsIntToDouble.kt | 1 + .../expressions/multipleSmartCasts.fir.kt.txt | 22 +++ .../expressions/multipleSmartCasts.fir.txt | 61 +++++++++ .../irText/expressions/multipleSmartCasts.kt | 13 ++ .../expressions/multipleSmartCasts.kt.txt | 24 ++++ .../irText/expressions/multipleSmartCasts.txt | 61 +++++++++ .../whenSmartCastToEnum.fir.kt.txt | 54 ++++++++ .../expressions/whenSmartCastToEnum.fir.txt | 124 +++++++++++++++++ .../irText/expressions/whenSmartCastToEnum.kt | 23 ++++ .../expressions/whenSmartCastToEnum.kt.txt | 56 ++++++++ .../expressions/whenSmartCastToEnum.txt | 126 ++++++++++++++++++ ...ackBoxAgainstJavaCodegenTestGenerated.java | 5 + .../codegen/BlackBoxCodegenTestGenerated.java | 10 ++ .../LightAnalysisModeTestGenerated.java | 10 ++ ...ackBoxAgainstJavaCodegenTestGenerated.java | 5 + .../ir/IrBlackBoxCodegenTestGenerated.java | 10 ++ .../kotlin/ir/IrTextTestCaseGenerated.java | 10 ++ .../IrJsCodegenBoxES6TestGenerated.java | 10 ++ .../IrJsCodegenBoxTestGenerated.java | 10 ++ .../semantics/JsCodegenBoxTestGenerated.java | 10 ++ .../IrCodegenBoxWasmTestGenerated.java | 10 ++ 28 files changed, 732 insertions(+), 18 deletions(-) create mode 100644 compiler/testData/codegen/box/ieee754/smartCastToInt.kt create mode 100644 compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt create mode 100644 compiler/testData/codegen/boxAgainstJava/sam/smartCastSamConversion.kt delete mode 100644 compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.txt create mode 100644 compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt create mode 100644 compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt create mode 100644 compiler/testData/ir/irText/expressions/multipleSmartCasts.kt create mode 100644 compiler/testData/ir/irText/expressions/multipleSmartCasts.kt.txt create mode 100644 compiler/testData/ir/irText/expressions/multipleSmartCasts.txt create mode 100644 compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.kt.txt create mode 100644 compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.txt create mode 100644 compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt create mode 100644 compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt.txt create mode 100644 compiler/testData/ir/irText/expressions/whenSmartCastToEnum.txt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxAgainstJavaCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxAgainstJavaCodegenTestGenerated.java index 4fb4b1e293d..784f8b3cdcb 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxAgainstJavaCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxAgainstJavaCodegenTestGenerated.java @@ -710,6 +710,11 @@ public class FirBlackBoxAgainstJavaCodegenTestGenerated extends AbstractFirBlack runTest("compiler/testData/codegen/boxAgainstJava/sam/samConstructorGenericSignature.kt"); } + @TestMetadata("smartCastSamConversion.kt") + public void testSmartCastSamConversion() throws Exception { + runTest("compiler/testData/codegen/boxAgainstJava/sam/smartCastSamConversion.kt"); + } + @TestMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 79721420c6e..779843e3493 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -13125,6 +13125,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); } + @TestMetadata("smartCastToInt.kt") + public void testSmartCastToInt() throws Exception { + runTest("compiler/testData/codegen/box/ieee754/smartCastToInt.kt"); + } + @TestMetadata("when.kt") public void testWhen() throws Exception { runTest("compiler/testData/codegen/box/ieee754/when.kt"); @@ -30781,6 +30786,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); } + @TestMetadata("multipleSmartCast.kt") + public void testMultipleSmartCast() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); + } + @TestMetadata("nullSmartCast.kt") public void testNullSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/nullSmartCast.kt"); diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 5384de8c033..6459d0e19a0 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1188,6 +1188,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/membersImportedFromObject.kt"); } + @TestMetadata("multipleSmartCasts.kt") + public void testMultipleSmartCasts() throws Exception { + runTest("compiler/testData/ir/irText/expressions/multipleSmartCasts.kt"); + } + @TestMetadata("multipleThisReferences.kt") public void testMultipleThisReferences() throws Exception { runTest("compiler/testData/ir/irText/expressions/multipleThisReferences.kt"); @@ -1453,6 +1458,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/whenReturnUnit.kt"); } + @TestMetadata("whenSmartCastToEnum.kt") + public void testWhenSmartCastToEnum() throws Exception { + runTest("compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt"); + } + @TestMetadata("whenUnusedExpression.kt") public void testWhenUnusedExpression() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenUnusedExpression.kt"); diff --git a/compiler/testData/codegen/box/ieee754/smartCastToInt.kt b/compiler/testData/codegen/box/ieee754/smartCastToInt.kt new file mode 100644 index 00000000000..c08e492291f --- /dev/null +++ b/compiler/testData/codegen/box/ieee754/smartCastToInt.kt @@ -0,0 +1,8 @@ +fun test(x: Any?, y: Double) = + x is Int && x < y + +fun box(): String = + if (!test(0, -0.0)) + "OK" + else + "Failed" diff --git a/compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt b/compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt new file mode 100644 index 00000000000..1fc0b74749b --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt @@ -0,0 +1,22 @@ +interface IC1 { + operator fun component1(): String +} + +interface IC2 { + operator fun component2(): String +} + +class A : IC1, IC2 { + override fun component1(): String = "O" + override fun component2(): String = "K" +} + +fun test(x: Any): String { + if (x is IC1 && x is IC2) { + val (x1, x2) = x + return "$x1$x2" + } + return "FAIL" +} + +fun box(): String = test(A()) \ No newline at end of file diff --git a/compiler/testData/codegen/boxAgainstJava/sam/smartCastSamConversion.kt b/compiler/testData/codegen/boxAgainstJava/sam/smartCastSamConversion.kt new file mode 100644 index 00000000000..563ecbc76a8 --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/sam/smartCastSamConversion.kt @@ -0,0 +1,22 @@ +// FILE: test.kt +fun test(a: Any) { + a as (String) -> String + J.use(a) +} + +fun box(): String { + test({s: String? -> s}) + return "OK" +} + +// FILE: JFoo.java +public interface JFoo { + T foo(T x); +} + +// FILE: J.java +public class J { + public static void use(JFoo jfoo) { + jfoo.foo(null); + } +} diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.txt deleted file mode 100644 index c9b9b99b311..00000000000 --- a/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.txt +++ /dev/null @@ -1,18 +0,0 @@ -FILE fqName: fileName:/nullableAnyAsIntToDouble.kt - FUN name:test visibility:public modality:FINAL <> (x:kotlin.Any?, y:kotlin.Double) returnType:kotlin.Boolean - VALUE_PARAMETER name:x index:0 type:kotlin.Any? - VALUE_PARAMETER name:y index:1 type:kotlin.Double - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test (x: kotlin.Any?, y: kotlin.Double): kotlin.Boolean declared in ' - WHEN type=kotlin.Boolean origin=ANDAND - BRANCH - if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Int - GET_VAR 'x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null - then: CALL 'public final fun less (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT - arg0: CALL 'public open fun toDouble (): kotlin.Double declared in kotlin.Int' type=kotlin.Double origin=null - $this: TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int - GET_VAR 'x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null - arg1: GET_VAR 'y: kotlin.Double declared in .test' type=kotlin.Double origin=null - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CONST Boolean type=kotlin.Boolean value=false diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.kt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.kt index ecbdc6d17aa..6876f02294c 100644 --- a/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.kt +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.kt @@ -1,2 +1,3 @@ +// FIR_IDENTICAL fun test(x: Any?, y: Double) = x is Int && x < y \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt new file mode 100644 index 00000000000..1cdd20ca6d0 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt @@ -0,0 +1,22 @@ +interface IC1 { + abstract operator fun component1(): Int + +} + +interface IC2 { + abstract operator fun component2(): String + +} + +fun test(x: Any) { + when { + when { + x is IC1 -> x /*as IC1 */ is IC2 + else -> false + } -> { // BLOCK + val : IC1 = x /*as IC1 */ + val x1: Int = .component1() + val x2: String = /*as IC2 */.component2() + } + } +} diff --git a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt new file mode 100644 index 00000000000..3f44bf5ad7f --- /dev/null +++ b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt @@ -0,0 +1,61 @@ +FILE fqName: fileName:/multipleSmartCasts.kt + CLASS INTERFACE name:IC1 modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IC1 + FUN name:component1 visibility:public modality:ABSTRACT <> ($this:.IC1) returnType:kotlin.Int [operator] + $this: VALUE_PARAMETER name: type:.IC1 + 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 [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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: 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: type:kotlin.Any + CLASS INTERFACE name:IC2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IC2 + FUN name:component2 visibility:public modality:ABSTRACT <> ($this:.IC2) returnType:kotlin.String [operator] + $this: VALUE_PARAMETER name: type:.IC2 + 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 [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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: 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: type:kotlin.Any + FUN name:test visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit + VALUE_PARAMETER name:x index:0 type:kotlin.Any + BLOCK_BODY + WHEN type=kotlin.Unit origin=IF + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.IC1 + GET_VAR 'x: kotlin.Any declared in .test' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.IC2 + TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 + GET_VAR 'x: kotlin.Any declared in .test' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.IC1 [val] + TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 + GET_VAR 'x: kotlin.Any declared in .test' type=kotlin.Any origin=null + VAR name:x1 type:kotlin.Int [val] + CALL 'public abstract fun component1 (): kotlin.Int [operator] declared in .IC1' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_0: .IC1 [val] declared in .test' type=.IC1 origin=null + VAR name:x2 type:kotlin.String [val] + CALL 'public abstract fun component2 (): kotlin.String [operator] declared in .IC2' type=kotlin.String origin=null + $this: TYPE_OP type=.IC2 origin=IMPLICIT_CAST typeOperand=.IC2 + GET_VAR 'val tmp_0: .IC1 [val] declared in .test' type=.IC1 origin=null diff --git a/compiler/testData/ir/irText/expressions/multipleSmartCasts.kt b/compiler/testData/ir/irText/expressions/multipleSmartCasts.kt new file mode 100644 index 00000000000..1eb9384ea67 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/multipleSmartCasts.kt @@ -0,0 +1,13 @@ +interface IC1 { + operator fun component1(): Int +} + +interface IC2 { + operator fun component2(): String +} + +fun test(x: Any) { + if (x is IC1 && x is IC2) { + val (x1, x2) = x + } +} diff --git a/compiler/testData/ir/irText/expressions/multipleSmartCasts.kt.txt b/compiler/testData/ir/irText/expressions/multipleSmartCasts.kt.txt new file mode 100644 index 00000000000..ca4c7ca8d04 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/multipleSmartCasts.kt.txt @@ -0,0 +1,24 @@ +interface IC1 { + abstract operator fun component1(): Int + +} + +interface IC2 { + abstract operator fun component2(): String + +} + +fun test(x: Any) { + when { + when { + x is IC1 -> x is IC2 + else -> false + } -> { // BLOCK + // COMPOSITE { + val tmp0_container: Any = x + val x1: Int = tmp0_container /*as IC1 */.component1() + val x2: String = tmp0_container /*as IC2 */.component2() + // } + } + } +} diff --git a/compiler/testData/ir/irText/expressions/multipleSmartCasts.txt b/compiler/testData/ir/irText/expressions/multipleSmartCasts.txt new file mode 100644 index 00000000000..3279f283ead --- /dev/null +++ b/compiler/testData/ir/irText/expressions/multipleSmartCasts.txt @@ -0,0 +1,61 @@ +FILE fqName: fileName:/multipleSmartCasts.kt + CLASS INTERFACE name:IC1 modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IC1 + FUN name:component1 visibility:public modality:ABSTRACT <> ($this:.IC1) returnType:kotlin.Int [operator] + $this: VALUE_PARAMETER name: type:.IC1 + 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 [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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: 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: type:kotlin.Any + CLASS INTERFACE name:IC2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IC2 + FUN name:component2 visibility:public modality:ABSTRACT <> ($this:.IC2) returnType:kotlin.String [operator] + $this: VALUE_PARAMETER name: type:.IC2 + 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 [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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: 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: type:kotlin.Any + FUN name:test visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit + VALUE_PARAMETER name:x index:0 type:kotlin.Any + BLOCK_BODY + WHEN type=kotlin.Unit origin=IF + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.IC1 + GET_VAR 'x: kotlin.Any declared in .test' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.IC2 + GET_VAR 'x: kotlin.Any declared in .test' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: BLOCK type=kotlin.Unit origin=null + COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any [val] + GET_VAR 'x: kotlin.Any declared in .test' type=kotlin.Any origin=null + VAR name:x1 type:kotlin.Int [val] + CALL 'public abstract fun component1 (): kotlin.Int [operator] declared in .IC1' type=kotlin.Int origin=COMPONENT_N(index=1) + $this: TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 + GET_VAR 'val tmp_0: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null + VAR name:x2 type:kotlin.String [val] + CALL 'public abstract fun component2 (): kotlin.String [operator] declared in .IC2' type=kotlin.String origin=COMPONENT_N(index=2) + $this: TYPE_OP type=.IC2 origin=IMPLICIT_CAST typeOperand=.IC2 + GET_VAR 'val tmp_0: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.kt.txt b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.kt.txt new file mode 100644 index 00000000000..1b37d6124cf --- /dev/null +++ b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.kt.txt @@ -0,0 +1,54 @@ +enum class En : Enum { + private constructor() /* primary */ { + super/*Enum*/() + /* () */ + + } + + A = En() + + B = En() + + C = En() + + fun values(): Array /* Synthetic body for ENUM_VALUES */ + + fun valueOf(value: String): En /* Synthetic body for ENUM_VALUEOF */ + +} + +fun test() { + var r: String = "" + val x: Any? = En.A + when { + x /*as En */ is En -> { // BLOCK + val tmp0_subject: En = x /*as En */ + when { + EQEQ(arg0 = tmp0_subject, arg1 = En.A) -> { // BLOCK + r = "when1" + } + EQEQ(arg0 = tmp0_subject, arg1 = En.B) -> { // BLOCK + } + EQEQ(arg0 = tmp0_subject, arg1 = En.C) -> { // BLOCK + } + else -> noWhenBranchMatchedException() + } + } + } + val y: Any = En.A + when { + y /*as En */ is En -> { // BLOCK + val tmp1_subject: En = y /*as En */ + when { + EQEQ(arg0 = tmp1_subject, arg1 = En.A) -> { // BLOCK + r = "when2" + } + EQEQ(arg0 = tmp1_subject, arg1 = En.B) -> { // BLOCK + } + EQEQ(arg0 = tmp1_subject, arg1 = En.C) -> { // BLOCK + } + else -> noWhenBranchMatchedException() + } + } + } +} diff --git a/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.txt b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.txt new file mode 100644 index 00000000000..21bab26d0bf --- /dev/null +++ b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.txt @@ -0,0 +1,124 @@ +FILE fqName: fileName:/whenSmartCastToEnum.kt + CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<.En>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.En + CONSTRUCTOR visibility:private <> () returnType:.En [primary] + BLOCK_BODY + ENUM_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' + : .En + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<.En>]' + ENUM_ENTRY name:A + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' + ENUM_ENTRY name:B + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' + ENUM_ENTRY name:C + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' + FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<.En> + SYNTHETIC_BODY kind=ENUM_VALUES + FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:.En + VALUE_PARAMETER name:value index:0 type:kotlin.String + SYNTHETIC_BODY kind=ENUM_VALUEOF + FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] + overridden: + protected final fun clone (): kotlin.Any declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.En) returnType:kotlin.Int [fake_override,operator] + overridden: + public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + VALUE_PARAMETER name:other index:0 type:.En + FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] + overridden: + public final fun hashCode (): kotlin.Int declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.String declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Int declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:r type:kotlin.String [var] + CONST String type=kotlin.String value="" + VAR name:x type:kotlin.Any? [val] + GET_ENUM 'ENUM_ENTRY name:A' type=.En + WHEN type=kotlin.Unit origin=IF + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.En + TYPE_OP type=.En origin=IMPLICIT_CAST typeOperand=.En + GET_VAR 'val x: kotlin.Any? [val] declared in .test' type=kotlin.Any? origin=null + then: BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.En [val] + TYPE_OP type=.En origin=IMPLICIT_CAST typeOperand=.En + GET_VAR 'val x: kotlin.Any? [val] declared in .test' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:A' type=.En + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var r: kotlin.String [var] declared in .test' type=kotlin.Unit origin=EQ + CONST String type=kotlin.String value="when1" + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:B' type=.En + then: BLOCK type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:C' type=.En + then: BLOCK type=kotlin.Unit origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null + VAR name:y type:kotlin.Any [val] + GET_ENUM 'ENUM_ENTRY name:A' type=.En + WHEN type=kotlin.Unit origin=IF + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.En + TYPE_OP type=.En origin=IMPLICIT_CAST typeOperand=.En + GET_VAR 'val y: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null + then: BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.En [val] + TYPE_OP type=.En origin=IMPLICIT_CAST typeOperand=.En + GET_VAR 'val y: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:A' type=.En + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var r: kotlin.String [var] declared in .test' type=kotlin.Unit origin=EQ + CONST String type=kotlin.String value="when2" + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:B' type=.En + then: BLOCK type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:C' type=.En + then: BLOCK type=kotlin.Unit origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null diff --git a/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt new file mode 100644 index 00000000000..f6f7c3ad1a2 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt @@ -0,0 +1,23 @@ +enum class En { A, B, C } + +fun test() { + var r = "" + + val x: Any? = En.A + if (x is En) { + when (x) { + En.A -> { r = "when1" } + En.B -> {} + En.C -> {} + } + } + + val y: Any = En.A + if (y is En) { + when (y) { + En.A -> { r = "when2" } + En.B -> {} + En.C -> {} + } + } +} diff --git a/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt.txt b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt.txt new file mode 100644 index 00000000000..4ec7d8471ab --- /dev/null +++ b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt.txt @@ -0,0 +1,56 @@ +enum class En : Enum { + private constructor() /* primary */ { + super/*Enum*/() + /* () */ + + } + + A = En() + + B = En() + + C = En() + + fun values(): Array /* Synthetic body for ENUM_VALUES */ + + fun valueOf(value: String): En /* Synthetic body for ENUM_VALUEOF */ + +} + +fun test() { + var r: String = "" + val x: Any? = En.A + when { + x is En -> { // BLOCK + { // BLOCK + val tmp0_subject: En = x /*as En */ + when { + EQEQ(arg0 = tmp0_subject, arg1 = En.A) -> { // BLOCK + r = "when1" + } + EQEQ(arg0 = tmp0_subject, arg1 = En.B) -> { // BLOCK + } + EQEQ(arg0 = tmp0_subject, arg1 = En.C) -> { // BLOCK + } + } + } + } + } + val y: Any = En.A + when { + y is En -> { // BLOCK + { // BLOCK + val tmp1_subject: En = y /*as En */ + when { + EQEQ(arg0 = tmp1_subject, arg1 = En.A) -> { // BLOCK + r = "when2" + } + EQEQ(arg0 = tmp1_subject, arg1 = En.B) -> { // BLOCK + } + EQEQ(arg0 = tmp1_subject, arg1 = En.C) -> { // BLOCK + } + } + } + } + } +} diff --git a/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.txt b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.txt new file mode 100644 index 00000000000..c20180ab65b --- /dev/null +++ b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.txt @@ -0,0 +1,126 @@ +FILE fqName: fileName:/whenSmartCastToEnum.kt + CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<.En>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.En + CONSTRUCTOR visibility:private <> () returnType:.En [primary] + BLOCK_BODY + ENUM_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' + : .En + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<.En>]' + ENUM_ENTRY name:A + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' + ENUM_ENTRY name:B + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' + ENUM_ENTRY name:C + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' + FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<.En>) returnType:kotlin.Any [fake_override] + overridden: + protected final fun clone (): kotlin.Any declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.En> + FUN FAKE_OVERRIDE name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum<.En>) returnType:kotlin.Unit [fake_override] + overridden: + protected/*protected and package*/ final fun finalize (): kotlin.Unit declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.En> + FUN FAKE_OVERRIDE name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum<.En>) returnType:@[FlexibleNullability] java.lang.Class<@[FlexibleNullability] .En?>? [fake_override] + overridden: + public final fun getDeclaringClass (): @[FlexibleNullability] java.lang.Class<@[FlexibleNullability] E of kotlin.Enum?>? declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.En> + FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum<.En>, other:.En) returnType:kotlin.Int [fake_override,operator] + overridden: + public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.En> + VALUE_PARAMETER name:other index:0 type:.En + FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum<.En>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.En> + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum<.En>) returnType:kotlin.Int [fake_override] + overridden: + public final fun hashCode (): kotlin.Int declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.En> + PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum<.En>) returnType:kotlin.String [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.String declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.En> + PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum<.En>) returnType:kotlin.Int [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Int declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.En> + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<.En>) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.En> + FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<.En> + SYNTHETIC_BODY kind=ENUM_VALUES + FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:.En + VALUE_PARAMETER name:value index:0 type:kotlin.String + SYNTHETIC_BODY kind=ENUM_VALUEOF + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:r type:kotlin.String [var] + CONST String type=kotlin.String value="" + VAR name:x type:kotlin.Any? [val] + GET_ENUM 'ENUM_ENTRY name:A' type=.En + WHEN type=kotlin.Unit origin=IF + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.En + GET_VAR 'val x: kotlin.Any? [val] declared in .test' type=kotlin.Any? origin=null + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.En [val] + TYPE_OP type=.En origin=IMPLICIT_CAST typeOperand=.En + GET_VAR 'val x: kotlin.Any? [val] declared in .test' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:A' type=.En + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var r: kotlin.String [var] declared in .test' type=kotlin.Unit origin=EQ + CONST String type=kotlin.String value="when1" + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:B' type=.En + then: BLOCK type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:C' type=.En + then: BLOCK type=kotlin.Unit origin=null + VAR name:y type:kotlin.Any [val] + GET_ENUM 'ENUM_ENTRY name:A' type=.En + WHEN type=kotlin.Unit origin=IF + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.En + GET_VAR 'val y: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.En [val] + TYPE_OP type=.En origin=IMPLICIT_CAST typeOperand=.En + GET_VAR 'val y: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:A' type=.En + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var r: kotlin.String [var] declared in .test' type=kotlin.Unit origin=EQ + CONST String type=kotlin.String value="when2" + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:B' type=.En + then: BLOCK type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: .En [val] declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:C' type=.En + then: BLOCK type=kotlin.Unit origin=null diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxAgainstJavaCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxAgainstJavaCodegenTestGenerated.java index 322d706ae67..837d3d2cbd0 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxAgainstJavaCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxAgainstJavaCodegenTestGenerated.java @@ -740,6 +740,11 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxAga runTest("compiler/testData/codegen/boxAgainstJava/sam/samConstructorGenericSignature.kt"); } + @TestMetadata("smartCastSamConversion.kt") + public void testSmartCastSamConversion() throws Exception { + runTest("compiler/testData/codegen/boxAgainstJava/sam/smartCastSamConversion.kt"); + } + @TestMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 4759421672c..7c749d7fd15 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -13125,6 +13125,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); } + @TestMetadata("smartCastToInt.kt") + public void testSmartCastToInt() throws Exception { + runTest("compiler/testData/codegen/box/ieee754/smartCastToInt.kt"); + } + @TestMetadata("when.kt") public void testWhen() throws Exception { runTest("compiler/testData/codegen/box/ieee754/when.kt"); @@ -31147,6 +31152,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); } + @TestMetadata("multipleSmartCast.kt") + public void testMultipleSmartCast() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); + } + @TestMetadata("nullSmartCast.kt") public void testNullSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/nullSmartCast.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 0bde74ea74d..1faddd7267d 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13125,6 +13125,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); } + @TestMetadata("smartCastToInt.kt") + public void testSmartCastToInt() throws Exception { + runTest("compiler/testData/codegen/box/ieee754/smartCastToInt.kt"); + } + @TestMetadata("when.kt") public void testWhen() throws Exception { runTest("compiler/testData/codegen/box/ieee754/when.kt"); @@ -28781,6 +28786,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); } + @TestMetadata("multipleSmartCast.kt") + public void testMultipleSmartCast() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); + } + @TestMetadata("nullSmartCast.kt") public void testNullSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/nullSmartCast.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxAgainstJavaCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxAgainstJavaCodegenTestGenerated.java index e3174981ecf..c9eb23e2af2 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxAgainstJavaCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxAgainstJavaCodegenTestGenerated.java @@ -710,6 +710,11 @@ public class IrBlackBoxAgainstJavaCodegenTestGenerated extends AbstractIrBlackBo runTest("compiler/testData/codegen/boxAgainstJava/sam/samConstructorGenericSignature.kt"); } + @TestMetadata("smartCastSamConversion.kt") + public void testSmartCastSamConversion() throws Exception { + runTest("compiler/testData/codegen/boxAgainstJava/sam/smartCastSamConversion.kt"); + } + @TestMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 027c3930b0f..03082fce39e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -13125,6 +13125,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); } + @TestMetadata("smartCastToInt.kt") + public void testSmartCastToInt() throws Exception { + runTest("compiler/testData/codegen/box/ieee754/smartCastToInt.kt"); + } + @TestMetadata("when.kt") public void testWhen() throws Exception { runTest("compiler/testData/codegen/box/ieee754/when.kt"); @@ -30781,6 +30786,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); } + @TestMetadata("multipleSmartCast.kt") + public void testMultipleSmartCast() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); + } + @TestMetadata("nullSmartCast.kt") public void testNullSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/nullSmartCast.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 493a45eaf80..e64f9d6ebf1 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1187,6 +1187,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/expressions/membersImportedFromObject.kt"); } + @TestMetadata("multipleSmartCasts.kt") + public void testMultipleSmartCasts() throws Exception { + runTest("compiler/testData/ir/irText/expressions/multipleSmartCasts.kt"); + } + @TestMetadata("multipleThisReferences.kt") public void testMultipleThisReferences() throws Exception { runTest("compiler/testData/ir/irText/expressions/multipleThisReferences.kt"); @@ -1452,6 +1457,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/expressions/whenReturnUnit.kt"); } + @TestMetadata("whenSmartCastToEnum.kt") + public void testWhenSmartCastToEnum() throws Exception { + runTest("compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt"); + } + @TestMetadata("whenUnusedExpression.kt") public void testWhenUnusedExpression() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenUnusedExpression.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index c7d1f85aee0..57da1c7969c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -11220,6 +11220,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); } + @TestMetadata("smartCastToInt.kt") + public void testSmartCastToInt() throws Exception { + runTest("compiler/testData/codegen/box/ieee754/smartCastToInt.kt"); + } + @TestMetadata("whenNoSubject_properIeeeComparisons.kt") public void testWhenNoSubject_properIeeeComparisons() throws Exception { runTest("compiler/testData/codegen/box/ieee754/whenNoSubject_properIeeeComparisons.kt"); @@ -24857,6 +24862,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); } + @TestMetadata("multipleSmartCast.kt") + public void testMultipleSmartCast() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); + } + @TestMetadata("nullSmartCast.kt") public void testNullSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/nullSmartCast.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 01a8b2c3154..21759f0fc3e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -11220,6 +11220,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); } + @TestMetadata("smartCastToInt.kt") + public void testSmartCastToInt() throws Exception { + runTest("compiler/testData/codegen/box/ieee754/smartCastToInt.kt"); + } + @TestMetadata("whenNoSubject_properIeeeComparisons.kt") public void testWhenNoSubject_properIeeeComparisons() throws Exception { runTest("compiler/testData/codegen/box/ieee754/whenNoSubject_properIeeeComparisons.kt"); @@ -24857,6 +24862,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); } + @TestMetadata("multipleSmartCast.kt") + public void testMultipleSmartCast() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); + } + @TestMetadata("nullSmartCast.kt") public void testNullSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/nullSmartCast.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index e4ae8e42cd8..206472c6123 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -11275,6 +11275,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); } + @TestMetadata("smartCastToInt.kt") + public void testSmartCastToInt() throws Exception { + runTest("compiler/testData/codegen/box/ieee754/smartCastToInt.kt"); + } + @TestMetadata("when.kt") public void testWhen() throws Exception { runTest("compiler/testData/codegen/box/ieee754/when.kt"); @@ -24857,6 +24862,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); } + @TestMetadata("multipleSmartCast.kt") + public void testMultipleSmartCast() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); + } + @TestMetadata("nullSmartCast.kt") public void testNullSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/nullSmartCast.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index c0b3f5fc551..4ef011f76c0 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -5886,6 +5886,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); } + @TestMetadata("smartCastToInt.kt") + public void testSmartCastToInt() throws Exception { + runTest("compiler/testData/codegen/box/ieee754/smartCastToInt.kt"); + } + @TestMetadata("whenNoSubject_properIeeeComparisons.kt") public void testWhenNoSubject_properIeeeComparisons() throws Exception { runTest("compiler/testData/codegen/box/ieee754/whenNoSubject_properIeeeComparisons.kt"); @@ -13253,6 +13258,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/smartCasts/kt19100.kt"); } + @TestMetadata("multipleSmartCast.kt") + public void testMultipleSmartCast() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); + } + @TestMetadata("smartCastInsideIf.kt") public void testSmartCastInsideIf() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt");