From 6931220c8230c3c4dad25ce539ecadd7bab86bb1 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Thu, 14 Mar 2019 16:36:56 +0300 Subject: [PATCH] Explicitly referenced possible super types of forward declarations --- .../src/org/jetbrains/kotlin/backend/konan/InteropUtils.kt | 1 + .../src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/InteropUtils.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/InteropUtils.kt index dfeced21f5f..bca5a1c9501 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/InteropUtils.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/InteropUtils.kt @@ -35,6 +35,7 @@ internal class InteropBuiltIns(builtIns: KonanBuiltIns) { val cValuesRef = this.packageScope.getContributedClass("CValuesRef") val cValues = this.packageScope.getContributedClass("CValues") val cValue = this.packageScope.getContributedClass("CValue") + val cOpaque = this.packageScope.getContributedClass("COpaque") val cValueWrite = this.packageScope.getContributedFunctions("write") .single { it.extensionReceiverParameter?.type?.constructor?.declarationDescriptor == cValue } val cValueRead = this.packageScope.getContributedFunctions("readValue") diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt index bf3c229e029..b9287ad8a3f 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt @@ -206,6 +206,12 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val val interopAllocObjCObject = symbolTable.referenceSimpleFunction(context.interopBuiltIns.allocObjCObject) + // These are possible supertypes of forward declarations - we need to reference them explicitly to force their deserialization. + // TODO: Do it lazily. + val interopCOpaque = symbolTable.referenceClass(context.interopBuiltIns.cOpaque) + val interopObjCObject = symbolTable.referenceClass(context.interopBuiltIns.objCObject) + val interopObjCObjectBase = symbolTable.referenceClass(context.interopBuiltIns.objCObjectBase) + val interopObjCRelease = interopFunction("objc_release") val interopObjCRetain = interopFunction("objc_retain")