From a19fc4650b7d7a188dd5741614baf21ee4ac5247 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 20 Sep 2022 01:44:46 +0200 Subject: [PATCH] Workaround a problem in publishing kotlin-backend-native-for-ide --- .../kotlin/common-configuration.gradle.kts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/common-configuration.gradle.kts b/buildSrc/src/main/kotlin/common-configuration.gradle.kts index 92a10c1d265..7d89db18ba8 100644 --- a/buildSrc/src/main/kotlin/common-configuration.gradle.kts +++ b/buildSrc/src/main/kotlin/common-configuration.gradle.kts @@ -189,7 +189,25 @@ fun Project.configureKotlinCompilationOptions() { if (project.path in projectsWithEnabledContextReceivers) { freeCompilerArgs += "-Xcontext-receivers" } - if (!skipJvmDefaultAllForModule(project.path)) { + + if (project.path == ":kotlin-util-klib") { + // This is a temporary workaround for a configuration problem in kotlin-native. Namely, module `:kotlin-native-shared` + // depends on kotlin-util-klib from bootstrap for some reason (see `kotlin-native/shared/build.gradle.kts`), but when + // we're packing dependencies for the use in the IDE, we pass paths to the newly built libraries to Proguard + // (see `prepare/ide-plugin-dependencies/kotlin-backend-native-for-ide/build.gradle.kts`). + // + // So the code which was compiled against one version of a library, is analyzed by Proguard against another version. + // + // This is a bad situation for JVM default flag behavior specifically. If kotlin-util-klib from bootstrap is compiled + // in the old mode (with DefaultImpls for interfaces), then subclasses in kotlin-native-shared will also be generated + // in the old mode (with DefaultImpls). But then Proguard will analyze these subclasses and their DefaultImpls classes, + // and will observe calls to non-existing methods from DefaultImpls of the interfaces in kotlin-util-klib, and report + // an error. + // + // This change will most likely not be needed after the bootstrap, as soon as kotlin-util-klib is compiled with + // `-Xjvm-default=all`. + freeCompilerArgs += "-Xjvm-default=all-compatibility" + } else if (!skipJvmDefaultAllForModule(project.path)) { freeCompilerArgs += "-Xjvm-default=all" } }