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 b63b7ffddef..573d6f62a1d 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 @@ -33,6 +33,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() { const val WARN = "warn" const val ERROR = "error" const val ENABLE = "enable" + const val DEFAULT = "default" } @get:Transient @@ -108,7 +109,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() { valueDescription = "{enable|warn|error}", description = "Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier" ) - var coroutinesState: String? by NullableStringFreezableVar(WARN) + var coroutinesState: String? by NullableStringFreezableVar(DEFAULT) @Argument( value = "-Xnew-inference", @@ -208,7 +209,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() { when (coroutinesState) { CommonCompilerArguments.ERROR -> put(LanguageFeature.Coroutines, LanguageFeature.State.ENABLED_WITH_ERROR) CommonCompilerArguments.ENABLE -> put(LanguageFeature.Coroutines, LanguageFeature.State.ENABLED) - CommonCompilerArguments.WARN -> { + CommonCompilerArguments.WARN, CommonCompilerArguments.DEFAULT -> { } else -> { val message = "Invalid value of -Xcoroutines (should be: enable, warn or error): " + coroutinesState @@ -311,12 +312,23 @@ abstract class CommonCompilerArguments : CommonToolArguments() { ) } - return LanguageVersionSettingsImpl( + val languageVersionSettings = LanguageVersionSettingsImpl( languageVersion, ApiVersion.createByLanguageVersion(apiVersion), configureAnalysisFlags(collector), configureLanguageFeatures(collector) ) + + if (languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines)) { + if (coroutinesState != DEFAULT) { + collector.report( + CompilerMessageSeverity.STRONG_WARNING, + "-Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond" + ) + } + } + + return languageVersionSettings } private fun parseVersion(collector: MessageCollector, value: String?, versionOf: String): LanguageVersion? = diff --git a/compiler/testData/cli/jvm/coroutinesEnable.out b/compiler/testData/cli/jvm/coroutinesEnable.out index d86bac9de59..f91ef107ba5 100644 --- a/compiler/testData/cli/jvm/coroutinesEnable.out +++ b/compiler/testData/cli/jvm/coroutinesEnable.out @@ -1 +1,2 @@ +warning: -Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond OK diff --git a/compiler/testData/cli/jvm/coroutinesError.out b/compiler/testData/cli/jvm/coroutinesError.out index 2b99464d215..f91ef107ba5 100644 --- a/compiler/testData/cli/jvm/coroutinesError.out +++ b/compiler/testData/cli/jvm/coroutinesError.out @@ -1,4 +1,2 @@ -compiler/testData/cli/jvm/coroutines.kt:1:1: error: the feature "coroutines" is experimental and disabled (see: https://kotlinlang.org/docs/diagnostics/experimental-coroutines) -suspend fun simple() = 5 -^ -COMPILATION_ERROR \ No newline at end of file +warning: -Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond +OK diff --git a/compiler/testData/cli/jvm/coroutinesErrorAndEnable.out b/compiler/testData/cli/jvm/coroutinesErrorAndEnable.out index ac6ae4be5aa..d5e60387dd1 100644 --- a/compiler/testData/cli/jvm/coroutinesErrorAndEnable.out +++ b/compiler/testData/cli/jvm/coroutinesErrorAndEnable.out @@ -1,2 +1,3 @@ warning: argument -Xcoroutines is passed multiple times. Only the last value will be used: enable -OK \ No newline at end of file +warning: -Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond +OK diff --git a/compiler/testData/cli/jvm/coroutinesWarn.out b/compiler/testData/cli/jvm/coroutinesWarn.out index f06a42ab8cb..f91ef107ba5 100644 --- a/compiler/testData/cli/jvm/coroutinesWarn.out +++ b/compiler/testData/cli/jvm/coroutinesWarn.out @@ -1,4 +1,2 @@ -compiler/testData/cli/jvm/coroutines.kt:1:1: warning: the feature "coroutines" is experimental (see: https://kotlinlang.org/docs/diagnostics/experimental-coroutines) -suspend fun simple() = 5 -^ -OK \ No newline at end of file +warning: -Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond +OK diff --git a/compiler/testData/cli/jvm/releaseCoroutinesApiVersion1.2.out b/compiler/testData/cli/jvm/releaseCoroutinesApiVersion1.2.out index c0f53c29cfe..e4578165e96 100644 --- a/compiler/testData/cli/jvm/releaseCoroutinesApiVersion1.2.out +++ b/compiler/testData/cli/jvm/releaseCoroutinesApiVersion1.2.out @@ -1,4 +1,3 @@ -warning: language version 1.3 is experimental, there are no backwards compatibility guarantees for new language and library features compiler/testData/cli/jvm/releaseCoroutinesApiVersion1.2.kt:1:1: error: unsupported [cannot use release coroutines with api version less than 1.3] suspend fun dummy() {} ^ diff --git a/compiler/testData/multiplatform/compilerArguments/output.txt b/compiler/testData/multiplatform/compilerArguments/output.txt index 4c0afff7be9..48ea2319fee 100644 --- a/compiler/testData/multiplatform/compilerArguments/output.txt +++ b/compiler/testData/multiplatform/compilerArguments/output.txt @@ -1,3 +1,4 @@ -- Common -- Exit code: OK Output: +warning: -Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond diff --git a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt index a8a05a54087..35d34a6fdea 100644 --- a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt +++ b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt @@ -54,7 +54,7 @@ object CoroutineSupport { fun byCompilerArgumentsOrNull(arguments: CommonCompilerArguments?): LanguageFeature.State? = when (arguments?.coroutinesState) { CommonCompilerArguments.ENABLE -> LanguageFeature.State.ENABLED - CommonCompilerArguments.WARN -> LanguageFeature.State.ENABLED_WITH_WARNING + CommonCompilerArguments.WARN, CommonCompilerArguments.DEFAULT -> LanguageFeature.State.ENABLED_WITH_WARNING CommonCompilerArguments.ERROR -> LanguageFeature.State.ENABLED_WITH_ERROR else -> null }