From b7a215334e0d4590354043ee046c3a64696980e2 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 17 May 2022 21:11:01 +0200 Subject: [PATCH] KT-52409 Report error when using K2 with multi-platform --- .../cli/jvm/compiler/FirKotlinToJvmBytecodeCompiler.kt | 7 +++++++ .../cli/jvm/firMultiplatformCompilationWithError.out | 8 +------- .../cli/jvm/firMultiplatformCompilationWithoutErrors.out | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/FirKotlinToJvmBytecodeCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/FirKotlinToJvmBytecodeCompiler.kt index 4d87c876d17..216da932262 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/FirKotlinToJvmBytecodeCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/FirKotlinToJvmBytecodeCompiler.kt @@ -104,6 +104,13 @@ object FirKotlinToJvmBytecodeCompiler { return false } } + if (projectConfiguration.languageVersionSettings.supportsFeature(LanguageFeature.MultiPlatformProjects)) { + messageCollector.report( + CompilerMessageSeverity.ERROR, + "K2 compiler does not support multi-platform projects yet, so please remove -Xuse-k2 flag" + ) + return false + } val outputs = ArrayList>(chunk.size) val targetIds = projectConfiguration.get(JVMConfigurationKeys.MODULES)?.map(::TargetId) diff --git a/compiler/testData/cli/jvm/firMultiplatformCompilationWithError.out b/compiler/testData/cli/jvm/firMultiplatformCompilationWithError.out index faedd86bf73..7209222f18f 100644 --- a/compiler/testData/cli/jvm/firMultiplatformCompilationWithError.out +++ b/compiler/testData/cli/jvm/firMultiplatformCompilationWithError.out @@ -11,11 +11,5 @@ compiler or generated code. Use it at your own risk! warning: ATTENTION! This build uses experimental K2 compiler: -Xuse-k2 -compiler/testData/cli/jvm/firMultiplatformCompilationWithError/jvm.kt:1:18: error: actual class 'public abstract actual interface A : R|kotlin/Any|' has no corresponding members for expected class members: - - public abstract expect fun foo(): R|kotlin/Unit| - - -actual interface A - ^ +error: k2 compiler does not support multi-platform projects yet, so please remove -Xuse-k2 flag COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/firMultiplatformCompilationWithoutErrors.out b/compiler/testData/cli/jvm/firMultiplatformCompilationWithoutErrors.out index 12cc44ccf11..7209222f18f 100644 --- a/compiler/testData/cli/jvm/firMultiplatformCompilationWithoutErrors.out +++ b/compiler/testData/cli/jvm/firMultiplatformCompilationWithoutErrors.out @@ -11,4 +11,5 @@ compiler or generated code. Use it at your own risk! warning: ATTENTION! This build uses experimental K2 compiler: -Xuse-k2 -OK +error: k2 compiler does not support multi-platform projects yet, so please remove -Xuse-k2 flag +COMPILATION_ERROR