From 45953f03a505ed2a54185fa5407529ef48466578 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Fri, 29 Nov 2019 17:20:05 +0300 Subject: [PATCH] Properly handle top level properties of inline classes. (#3627) --- .../kotlin/backend/konan/llvm/IrToBitcode.kt | 2 +- backend.native/tests/runtime/workers/freeze3.kt | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index 0d1b2386447..38038845791 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -58,7 +58,7 @@ internal val IrField.storageClass: FieldStorage get() { } val IrField.isMainOnlyNonPrimitive get() = when { - KotlinBuiltIns.isPrimitiveType(descriptor.type) -> false + descriptor.type.computePrimitiveBinaryTypeOrNull() != null -> false else -> storageClass == FieldStorage.MAIN_THREAD } diff --git a/backend.native/tests/runtime/workers/freeze3.kt b/backend.native/tests/runtime/workers/freeze3.kt index ba49a4858cb..05dab88d7bf 100644 --- a/backend.native/tests/runtime/workers/freeze3.kt +++ b/backend.native/tests/runtime/workers/freeze3.kt @@ -18,7 +18,9 @@ object Mutable { var x = 2 } -@Test fun runTest() { +val topLevelInline: ULong = 0xc3a5c85c97cb3127U + +@Test fun runTest1() { assertEquals(1, AnObject.x) if (Platform.memoryModel == MemoryModel.STRICT) { assertFailsWith { @@ -34,3 +36,15 @@ object Mutable { assertEquals(3, Mutable.x) println("OK") } + +@Test fun runTest2() { + val ok = AtomicInt(0) + withWorker() { + executeAfter(0, { + assertEquals(0xc3a5c85c97cb3127U, topLevelInline) + ok.increment() + }.freeze()) + } + assertEquals(1, ok.value) +} +