From 183bf917eef7921a1e747b908dce0e2443f2a057 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Fri, 23 Mar 2018 13:50:44 +0300 Subject: [PATCH] Fixed bug in InlineCopyIr with IrGetClass + test --- .../lower/DeepCopyIrTreeWithDescriptors.kt | 1 - backend.native/tests/build.gradle | 5 +++++ .../tests/codegen/inline/getClass.kt | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 backend.native/tests/codegen/inline/getClass.kt diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt index 72efe99c91b..08e10ac244d 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt @@ -597,7 +597,6 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr override fun visitGetClass(expression: IrGetClass): IrGetClass { val type = substituteType(expression.type)!! - if (type == expression.type) return expression return IrGetClassImpl( startOffset = expression.startOffset, endOffset = expression.endOffset, diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index bd14f312f08..a218a76a1fb 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -2261,6 +2261,11 @@ task inline_lambdaAsAny(type: RunKonanTest) { source = "codegen/inline/lambdaAsAny.kt" } +task inline_getClass(type: RunKonanTest) { + goldValue = "OK\n" + source = "codegen/inline/getClass.kt" +} + task deserialized_inline0(type: RunKonanTest) { source = "serialization/deserialized_inline0.kt" } diff --git a/backend.native/tests/codegen/inline/getClass.kt b/backend.native/tests/codegen/inline/getClass.kt new file mode 100644 index 00000000000..fd4a080c26d --- /dev/null +++ b/backend.native/tests/codegen/inline/getClass.kt @@ -0,0 +1,18 @@ +package codegen.inline.getClass + +import kotlin.test.* + +fun foo() { + val cls1: Any? = Int + val cls2: Any? = null + + cls1?.let { + cls2?.let { + var itClass = it::class + } + } +} + +@Test fun runTest() { + println("OK") +}