K2 tests: always use language version 2.0 or higher

This commit is contained in:
Mikhail Glukhikh
2023-03-02 10:52:16 +01:00
committed by Space Team
parent d9a6cad5ab
commit fbea09b3b6
2 changed files with 11 additions and 2 deletions
@@ -53,7 +53,8 @@ class LanguageVersionSettingsBuilder {
fun configureUsingDirectives( fun configureUsingDirectives(
directives: RegisteredDirectives, directives: RegisteredDirectives,
environmentConfigurators: List<AbstractEnvironmentConfigurator>, environmentConfigurators: List<AbstractEnvironmentConfigurator>,
targetBackend: TargetBackend? targetBackend: TargetBackend?,
useK2: Boolean
) { ) {
val apiVersion = directives.singleOrZeroValue(LanguageSettingsDirectives.API_VERSION) val apiVersion = directives.singleOrZeroValue(LanguageSettingsDirectives.API_VERSION)
if (apiVersion != null) { if (apiVersion != null) {
@@ -61,6 +62,10 @@ class LanguageVersionSettingsBuilder {
val languageVersion = maxOf(LanguageVersion.LATEST_STABLE, LanguageVersion.fromVersionString(apiVersion.versionString)!!) val languageVersion = maxOf(LanguageVersion.LATEST_STABLE, LanguageVersion.fromVersionString(apiVersion.versionString)!!)
this.languageVersion = languageVersion this.languageVersion = languageVersion
} }
when {
useK2 && this.languageVersion < LanguageVersion.KOTLIN_2_0 -> this.languageVersion = LanguageVersion.KOTLIN_2_0
!useK2 && this.languageVersion > LanguageVersion.KOTLIN_1_9 -> this.languageVersion = LanguageVersion.KOTLIN_1_9
}
val analysisFlags = listOfNotNull( val analysisFlags = listOfNotNull(
analysisFlag(AnalysisFlags.optIn, directives[LanguageSettingsDirectives.OPT_IN].takeIf { it.isNotEmpty() }), analysisFlag(AnalysisFlags.optIn, directives[LanguageSettingsDirectives.OPT_IN].takeIf { it.isNotEmpty() }),
@@ -334,7 +334,11 @@ class ModuleStructureExtractorImpl(
moduleDirectives.forEach { it.checkDirectiveApplicability(contextIsGlobal = isImplicitModule, contextIsModule = true) } moduleDirectives.forEach { it.checkDirectiveApplicability(contextIsGlobal = isImplicitModule, contextIsModule = true) }
val targetBackend = currentModuleTargetBackend ?: defaultsProvider.defaultTargetBackend val targetBackend = currentModuleTargetBackend ?: defaultsProvider.defaultTargetBackend
currentModuleLanguageVersionSettingsBuilder.configureUsingDirectives(moduleDirectives, environmentConfigurators, targetBackend) val frontendKind = currentModuleFrontendKind ?: defaultsProvider.defaultFrontend
currentModuleLanguageVersionSettingsBuilder.configureUsingDirectives(
moduleDirectives, environmentConfigurators, targetBackend, useK2 = frontendKind == FrontendKinds.FIR
)
val moduleName = currentModuleName val moduleName = currentModuleName
?: testServices.defaultDirectives[ModuleStructureDirectives.MODULE].firstOrNull() ?: testServices.defaultDirectives[ModuleStructureDirectives.MODULE].firstOrNull()
?: DEFAULT_MODULE_NAME ?: DEFAULT_MODULE_NAME