Report error if IR is enabled with incorrect language version
^KT-36338 Fixed
This commit is contained in:
+5
@@ -497,6 +497,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
)
|
||||
|
||||
checkCoroutines(languageVersionSettings, collector)
|
||||
checkIrSupport(languageVersionSettings, collector)
|
||||
|
||||
return languageVersionSettings
|
||||
}
|
||||
@@ -577,6 +578,10 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun checkIrSupport(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
|
||||
// backend-specific
|
||||
}
|
||||
|
||||
private enum class VersionKind(val text: String) {
|
||||
LANGUAGE("Language"), API("API")
|
||||
}
|
||||
|
||||
+18
@@ -18,6 +18,11 @@ package org.jetbrains.kotlin.cli.common.arguments
|
||||
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.CALL
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.NO_CALL
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.config.ApiVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
|
||||
class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
companion object {
|
||||
@@ -164,6 +169,19 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@Argument(value = "-Xenable-js-scripting", description = "Enable experimental support of .kts files using K/JS (with -Xir only)")
|
||||
var enableJsScripting: Boolean by FreezableVar(false)
|
||||
|
||||
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"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun K2JSCompilerArguments.isPreIrBackendDisabled(): Boolean =
|
||||
|
||||
+13
@@ -352,4 +352,17 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun checkIrSupport(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
|
||||
if (!useIR) return
|
||||
|
||||
if (languageVersionSettings.languageVersion < LanguageVersion.KOTLIN_1_3
|
||||
|| languageVersionSettings.apiVersion < ApiVersion.KOTLIN_1_3
|
||||
) {
|
||||
collector.report(
|
||||
CompilerMessageSeverity.ERROR,
|
||||
"IR backend cannot be used with language or API version below 1.3"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user