From 710381e489aac68dd4092ece8ac191cdace15d9e Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Mon, 10 Jul 2023 16:15:49 +0000 Subject: [PATCH] Native: don't report Objective-C-related errors on expect classes An expect class might lack some details and thus seem incorrect to the compiler, while the corresponding actual class is totally fine. Due to the specifics of the compiler, this happens more often then it should (because the compiler actually always analyzes expects along with actuals, with most references actualized). For example, in KT-52882 the compiler analyzes an expect class (TestImpl), but the class refers to the actual interface Test as its supertype, meaning that the compiler sees TestImpl as a class inheriting an Objective-C protocol but not an Objective-C class, which is prohibited. While the actual class has its super types in order. So, in reality, from both actualized and non-actualized points of view, the code is totally correct, and the error was reported only because of the way the compiler handles multiplatform. Those compiler checks only matter for the actual class anyway, so disabling them for expect classes is harmless. ^KT-52882 Fixed --- .../kotlin/backend/konan/lower/SpecialBackendChecksTraversal.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SpecialBackendChecksTraversal.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SpecialBackendChecksTraversal.kt index e7db1edc209..4e0796f0c47 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SpecialBackendChecksTraversal.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SpecialBackendChecksTraversal.kt @@ -593,7 +593,7 @@ private class BackendChecker( } override fun visitClass(declaration: IrClass) { - if (declaration.isKotlinObjCClass()) { + if (!declaration.isExpect && declaration.isKotlinObjCClass()) { checkKotlinObjCClass(declaration) } super.visitClass(declaration)