Workaround a problem in publishing kotlin-backend-native-for-ide

This commit is contained in:
Alexander Udalov
2022-09-20 01:44:46 +02:00
parent fc8cb40a0d
commit a19fc4650b
@@ -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"
}
}