From 37bcd0894f2516b7a0e86e4948f7990925efecfa Mon Sep 17 00:00:00 2001 From: SvyatoslavScherbina Date: Wed, 13 Jan 2021 12:28:24 +0300 Subject: [PATCH] Workaround inconsistent descriptor for Any.hashCode in ObjCExport Recent changes to IR (adopted in https://github.com/JetBrains/kotlin-native/pull/4621) have broken some invariants Native backend relies on, in particular now `hashCodeIrFunction.descriptor.containingDeclaration` is not `builtIns.any`, but is an "IR-based" descriptor which has same fq name. This breaks ObjCExport's predicate detecting `hashCode` (which in turn breaks `interop_objc_smoke` test in two-stage mode). This commit doesn't fix the invariants, but workarounds the problem by making the predicate more flexible. --- .../kotlin/backend/konan/objcexport/ObjCExportMapper.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt index fa96217dcda..a08578d85fe 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt @@ -265,7 +265,8 @@ private fun ObjCExportMapper.bridgeReturnType( } } - descriptor.containingDeclaration == descriptor.builtIns.any && descriptor.name.asString() == "hashCode" -> { + descriptor.containingDeclaration.let { it is ClassDescriptor && KotlinBuiltIns.isAny(it) } && + descriptor.name.asString() == "hashCode" -> { assert(!convertExceptionsToErrors) MethodBridge.ReturnValue.HashCode }