Revert "Remove obsolete check for language version and IR backends"
This check is no longer obsolete since language version 1.3 support is
restored for Kotlin/JVM, but JS and Native never supported LV 1.3.
This is a partial revert of 0213c25c9b67ee6aed4ac71f9c682c168c99fd33,
without the diagnostic in K2JVMCompilerArguments (which is not needed
since the earliest supported LV is 1.3).
#KT-50695 Fixed
diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt
index 2fdb525..7589ee2 100644
--- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt
+++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt
@@ -574,6 +574,8 @@
checkLanguageVersionIsStable(languageVersion, collector)
checkOutdatedVersions(languageVersion, apiVersion, collector)
checkProgressiveMode(languageVersion, collector)
+
+ checkIrSupport(languageVersionSettings, collector)
}
checkPlatformSpecificSettings(languageVersionSettings, collector)
@@ -652,6 +654,10 @@
protected open fun checkPlatformSpecificSettings(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
}
+ protected open fun checkIrSupport(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
+ // backend-specific
+ }
+
private enum class VersionKind(val text: String) {
LANGUAGE("Language"), API("API")
}
diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt
index d8d0ca6..0c4f47b 100644
--- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt
+++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt
@@ -6,11 +6,10 @@
package org.jetbrains.kotlin.cli.common.arguments
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.*
+import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
-import org.jetbrains.kotlin.config.AnalysisFlag
+import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.config.AnalysisFlags.allowFullyQualifiedNameInKClass
-import org.jetbrains.kotlin.config.LanguageFeature
-import org.jetbrains.kotlin.config.LanguageVersion
class K2JSCompilerArguments : CommonCompilerArguments() {
companion object {
@@ -257,6 +256,19 @@
}
}
+ override fun checkIrSupport(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
+ if (!isIrBackendEnabled()) return
+
+ if (languageVersionSettings.languageVersion < LanguageVersion.KOTLIN_1_4
+ || languageVersionSettings.apiVersion < ApiVersion.KOTLIN_1_4
+ ) {
+ collector.report(
+ CompilerMessageSeverity.ERROR,
+ "IR backend cannot be used with language or API version below 1.4"
+ )
+ }
+ }
+
override fun configureLanguageFeatures(collector: MessageCollector): MutableMap<LanguageFeature, LanguageFeature.State> {
return super.configureLanguageFeatures(collector).apply {
if (extensionFunctionsInExternals) {
diff --git a/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt b/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt
index 2010cff..1545894 100644
--- a/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt
+++ b/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt
@@ -371,6 +371,17 @@
if (printIr)
phasesToDumpAfter = arrayOf("ALL")
}
+
+ override fun checkIrSupport(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
+ if (languageVersionSettings.languageVersion < LanguageVersion.KOTLIN_1_4
+ || languageVersionSettings.apiVersion < ApiVersion.KOTLIN_1_4
+ ) {
+ collector.report(
+ severity = CompilerMessageSeverity.ERROR,
+ message = "Native backend cannot be used with language or API version below 1.4"
+ )
+ }
+ }
}
const val EMBED_BITCODE_FLAG = "-Xembed-bitcode"