From a82772f31a9fae370c774adc951a37cd6c07f437 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Fri, 11 Jun 2021 10:25:29 +0300 Subject: [PATCH] Depend on passed language version explicitly to compute nullability annotation settings --- .../arguments/CommonCompilerArguments.kt | 4 +- .../JavaTypeEnhancementStateParser.kt | 38 +++++++++++++------ .../arguments/K2JVMCompilerArguments.kt | 12 ++---- .../LanguageVersionSettingsBuilder.kt | 2 +- .../test/services/EnvironmentConfigurator.kt | 6 ++- compiler/testData/cli/jvm/jspecifyByLv15.args | 7 ++++ compiler/testData/cli/jvm/jspecifyByLv15.out | 7 ++++ compiler/testData/cli/jvm/jspecifyByLv16.args | 7 ++++ compiler/testData/cli/jvm/jspecifyByLv16.out | 5 +++ .../JvmForeignAnnotationsConfigurator.kt | 11 +++--- .../kotlin/cli/CliTestGenerated.java | 10 +++++ .../kotlin/config/LanguageVersionSettings.kt | 2 + .../java/JavaNullabilityAnnotationSettings.kt | 22 ++++++----- .../load/java/JavaTypeEnhancementState.kt | 6 +-- .../kotlin/load/java/Jsr305Settings.kt | 4 -- .../compiler/IDELanguageSettingsProvider.kt | 6 ++- 16 files changed, 102 insertions(+), 47 deletions(-) create mode 100644 compiler/testData/cli/jvm/jspecifyByLv15.args create mode 100644 compiler/testData/cli/jvm/jspecifyByLv15.out create mode 100644 compiler/testData/cli/jvm/jspecifyByLv16.args create mode 100644 compiler/testData/cli/jvm/jspecifyByLv16.out 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 e55da1c1074..cce917df61a 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 @@ -365,7 +365,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() { ) var extendedCompilerChecks: Boolean by FreezableVar(false) - open fun configureAnalysisFlags(collector: MessageCollector): MutableMap, Any> { + open fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap, Any> { return HashMap, Any>().apply { put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck) put(AnalysisFlags.skipPrereleaseCheck, skipPrereleaseCheck || skipMetadataVersionCheck) @@ -516,7 +516,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() { val languageVersionSettings = LanguageVersionSettingsImpl( languageVersion, ApiVersion.createByLanguageVersion(apiVersion), - configureAnalysisFlags(collector), + configureAnalysisFlags(collector, languageVersion), configureLanguageFeatures(collector) ) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/JavaTypeEnhancementStateParser.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/JavaTypeEnhancementStateParser.kt index 4e036e16a23..6b8a625ddcb 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/JavaTypeEnhancementStateParser.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/JavaTypeEnhancementStateParser.kt @@ -22,34 +22,45 @@ import org.jetbrains.kotlin.load.java.* import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.isSubpackageOf -class JavaTypeEnhancementStateParser(private val collector: MessageCollector) { +class JavaTypeEnhancementStateParser( + private val collector: MessageCollector, + private val kotlinVersion: KotlinVersion +) { fun parse( jsr305Args: Array?, supportCompatqualCheckerFrameworkAnnotations: String?, jspecifyState: String?, - nullabilityAnnotations: Array?, + nullabilityAnnotations: Array? ): JavaTypeEnhancementState { + val nullabilityAnnotationReportLevels = parseNullabilityAnnotationReportLevels(nullabilityAnnotations) val compatqualCheckerFrameworkAnnotationsReportLevel = when (supportCompatqualCheckerFrameworkAnnotations) { "enable" -> ReportLevel.STRICT "disable" -> ReportLevel.IGNORE - null -> getDefaultReportLevelForAnnotation(CHECKER_FRAMEWORK_COMPATQUAL_ANNOTATIONS_PACKAGE) + null -> getReportLevelForAnnotation( + CHECKER_FRAMEWORK_COMPATQUAL_ANNOTATIONS_PACKAGE, + nullabilityAnnotationReportLevels, + kotlinVersion + ) else -> { collector.report( CompilerMessageSeverity.ERROR, "Unrecognized -Xsupport-compatqual-checker-framework-annotations option: $supportCompatqualCheckerFrameworkAnnotations. Possible values are 'enable'/'disable'" ) - getDefaultReportLevelForAnnotation(CHECKER_FRAMEWORK_COMPATQUAL_ANNOTATIONS_PACKAGE) + getReportLevelForAnnotation( + CHECKER_FRAMEWORK_COMPATQUAL_ANNOTATIONS_PACKAGE, + nullabilityAnnotationReportLevels, + kotlinVersion + ) } } val jsr305Settings = parseJsr305State(jsr305Args) - val jspecifyReportLevel = parseJspecifyReportLevel(jspecifyState) - val nullabilityAnnotationReportLevels = parseNullabilityAnnotationReportLevels(nullabilityAnnotations) + val jspecifyReportLevel = parseJspecifyReportLevel(jspecifyState, nullabilityAnnotationReportLevels) return JavaTypeEnhancementState(jsr305Settings) { when { it.isSubpackageOf(JSPECIFY_ANNOTATIONS_PACKAGE) -> jspecifyReportLevel it.isSubpackageOf(CHECKER_FRAMEWORK_COMPATQUAL_ANNOTATIONS_PACKAGE) -> compatqualCheckerFrameworkAnnotationsReportLevel - else -> getReportLevelForAnnotation(it, nullabilityAnnotationReportLevels) + else -> getReportLevelForAnnotation(it, nullabilityAnnotationReportLevels, kotlinVersion) } } } @@ -79,9 +90,12 @@ class JavaTypeEnhancementStateParser(private val collector: MessageCollector) { return annotationsWithReportLevels } - private fun parseJspecifyReportLevel(jspecifyState: String?): ReportLevel { + private fun parseJspecifyReportLevel( + jspecifyState: String?, + nullabilityAnnotationReportLevels: NullabilityAnnotationStates + ): ReportLevel { if (jspecifyState == null) - return getDefaultReportLevelForAnnotation(JSPECIFY_ANNOTATIONS_PACKAGE) + return getReportLevelForAnnotation(JSPECIFY_ANNOTATIONS_PACKAGE, nullabilityAnnotationReportLevels, kotlinVersion) val reportLevel = ReportLevel.findByDescription(jspecifyState) @@ -90,7 +104,7 @@ class JavaTypeEnhancementStateParser(private val collector: MessageCollector) { CompilerMessageSeverity.ERROR, "Unrecognized -Xjspecify-annotations option: $jspecifyState. Possible values are 'disable'/'warn'/'strict'" ) - return getDefaultReportLevelForAnnotation(JSPECIFY_ANNOTATIONS_PACKAGE) + return getReportLevelForAnnotation(JSPECIFY_ANNOTATIONS_PACKAGE, nullabilityAnnotationReportLevels, kotlinVersion) } return reportLevel @@ -101,7 +115,7 @@ class JavaTypeEnhancementStateParser(private val collector: MessageCollector) { var migration: ReportLevel? = null val userDefined = mutableMapOf() val compilerOption = "-Xjsr305" - val defaultSettings = Jsr305Settings.DEFAULT + val defaultSettings = getDefaultJsr305Settings(kotlinVersion) fun parseJsr305UnderMigration(item: String): ReportLevel? { val rawState = item.split(":").takeIf { it.size == 2 }?.get(1) @@ -181,7 +195,7 @@ class JavaTypeEnhancementStateParser(private val collector: MessageCollector) { } companion object { - private val DEFAULT = JavaTypeEnhancementStateParser(MessageCollector.NONE) + private val DEFAULT = JavaTypeEnhancementStateParser(MessageCollector.NONE, KotlinVersion.CURRENT) fun parsePlainNullabilityAnnotationReportLevels(nullabilityAnnotations: String) = DEFAULT.parseNullabilityAnnotationReportLevels(arrayOf(nullabilityAnnotations)).entries.singleOrNull()?.toPair() diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index 8b3cb275122..08bdf6856f8 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -499,15 +499,11 @@ default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise"" ) var typeEnhancementImprovementsInStrictMode: Boolean by FreezableVar(false) - override fun configureAnalysisFlags(collector: MessageCollector): MutableMap, Any> { - val result = super.configureAnalysisFlags(collector) + override fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap, Any> { + val result = super.configureAnalysisFlags(collector, languageVersion) result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics - result[JvmAnalysisFlags.javaTypeEnhancementState] = JavaTypeEnhancementStateParser(collector).parse( - jsr305, - supportCompatqualCheckerFrameworkAnnotations, - jspecifyAnnotations, - nullabilityAnnotations - ) + result[JvmAnalysisFlags.javaTypeEnhancementState] = JavaTypeEnhancementStateParser(collector, languageVersion.toKotlinVersion()) + .parse(jsr305, supportCompatqualCheckerFrameworkAnnotations, jspecifyAnnotations, nullabilityAnnotations) result[AnalysisFlags.ignoreDataFlowInAssert] = JVMAssertionsMode.fromString(assertionsMode) != JVMAssertionsMode.LEGACY JvmDefaultMode.fromStringOrNull(jvmDefault)?.let { result[JvmAnalysisFlags.jvmDefaultMode] = it diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/builders/LanguageVersionSettingsBuilder.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/builders/LanguageVersionSettingsBuilder.kt index 02d27c0365a..76c214e60b0 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/builders/LanguageVersionSettingsBuilder.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/builders/LanguageVersionSettingsBuilder.kt @@ -83,7 +83,7 @@ class LanguageVersionSettingsBuilder { analysisFlags.forEach { withFlag(it.first, it.second) } environmentConfigurators.forEach { - it.provideAdditionalAnalysisFlags(directives).entries.forEach { (flag, value) -> + it.provideAdditionalAnalysisFlags(directives, languageVersion).entries.forEach { (flag, value) -> withFlag(flag, value) } } diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/EnvironmentConfigurator.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/EnvironmentConfigurator.kt index 40f4eb07b05..cffc9ea490d 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/EnvironmentConfigurator.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/EnvironmentConfigurator.kt @@ -9,6 +9,7 @@ import com.intellij.openapi.project.Project import org.jetbrains.kotlin.config.AnalysisFlag import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.CompilerConfigurationKey +import org.jetbrains.kotlin.config.LanguageVersion import org.jetbrains.kotlin.test.directives.model.* import org.jetbrains.kotlin.test.model.TestModule @@ -36,7 +37,10 @@ abstract class EnvironmentConfigurator(protected val testServices: TestServices) open fun DirectiveToConfigurationKeyExtractor.provideConfigurationKeys() {} - open fun provideAdditionalAnalysisFlags(directives: RegisteredDirectives): Map, Any?> { + open fun provideAdditionalAnalysisFlags( + directives: RegisteredDirectives, + languageVersion: LanguageVersion + ): Map, Any?> { return emptyMap() } diff --git a/compiler/testData/cli/jvm/jspecifyByLv15.args b/compiler/testData/cli/jvm/jspecifyByLv15.args new file mode 100644 index 00000000000..0339849b22c --- /dev/null +++ b/compiler/testData/cli/jvm/jspecifyByLv15.args @@ -0,0 +1,7 @@ +-language-version +1.5 +$TESTDATA_DIR$/jspecifyUsage.kt +$TESTDATA_DIR$/jspecify +$FOREIGN_ANNOTATIONS_DIR$ +-d +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/jspecifyByLv15.out b/compiler/testData/cli/jvm/jspecifyByLv15.out new file mode 100644 index 00000000000..7c2a6d77f6e --- /dev/null +++ b/compiler/testData/cli/jvm/jspecifyByLv15.out @@ -0,0 +1,7 @@ +compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected + a.foo(null) + ^ +compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String? + a.bar().hashCode() + ^ +OK diff --git a/compiler/testData/cli/jvm/jspecifyByLv16.args b/compiler/testData/cli/jvm/jspecifyByLv16.args new file mode 100644 index 00000000000..53e7fd977b8 --- /dev/null +++ b/compiler/testData/cli/jvm/jspecifyByLv16.args @@ -0,0 +1,7 @@ +-language-version +1.6 +$TESTDATA_DIR$/jspecifyUsage.kt +$TESTDATA_DIR$/jspecify +$FOREIGN_ANNOTATIONS_DIR$ +-d +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/jspecifyByLv16.out b/compiler/testData/cli/jvm/jspecifyByLv16.out new file mode 100644 index 00000000000..78f928f41f7 --- /dev/null +++ b/compiler/testData/cli/jvm/jspecifyByLv16.out @@ -0,0 +1,5 @@ +warning: language version 1.6 is experimental, there are no backwards compatibility guarantees for new language and library features +compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: error: null can not be a value of a non-null type String + a.foo(null) + ^ +COMPILATION_ERROR diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmForeignAnnotationsConfigurator.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmForeignAnnotationsConfigurator.kt index 02eb3d4cbbc..301ec87ae2d 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmForeignAnnotationsConfigurator.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmForeignAnnotationsConfigurator.kt @@ -9,9 +9,7 @@ import org.jetbrains.kotlin.cli.jvm.addModularRootIfNotNull import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime -import org.jetbrains.kotlin.config.AnalysisFlag -import org.jetbrains.kotlin.config.CompilerConfiguration -import org.jetbrains.kotlin.config.JvmAnalysisFlags +import org.jetbrains.kotlin.config.* import org.jetbrains.kotlin.load.java.* import org.jetbrains.kotlin.test.MockLibraryUtil import org.jetbrains.kotlin.test.TestJavacVersion @@ -46,8 +44,11 @@ open class JvmForeignAnnotationsConfigurator(testServices: TestServices) : Envir get() = listOf(ForeignAnnotationsDirectives) @OptIn(ExperimentalStdlibApi::class) - override fun provideAdditionalAnalysisFlags(directives: RegisteredDirectives): Map, Any?> { - val defaultJsr305Settings = Jsr305Settings.DEFAULT + override fun provideAdditionalAnalysisFlags( + directives: RegisteredDirectives, + languageVersion: LanguageVersion + ): Map, Any?> { + val defaultJsr305Settings = getDefaultJsr305Settings(languageVersion.toKotlinVersion()) val globalState = directives.singleOrZeroValue(JSR305_GLOBAL_REPORT) ?: defaultJsr305Settings.globalLevel val migrationState = directives.singleOrZeroValue(JSR305_MIGRATION_REPORT) ?: defaultJsr305Settings.migrationLevel val userAnnotationsState = directives[JSR305_SPECIAL_REPORT].mapNotNull { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java index 293a2255925..7bda4f3f4a8 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java @@ -446,6 +446,16 @@ public class CliTestGenerated extends AbstractCliTest { runTest("compiler/testData/cli/jvm/jdkPathDoesNotExist.args"); } + @TestMetadata("jspecifyByLv15.args") + public void testJspecifyByLv15() throws Exception { + runTest("compiler/testData/cli/jvm/jspecifyByLv15.args"); + } + + @TestMetadata("jspecifyByLv16.args") + public void testJspecifyByLv16() throws Exception { + runTest("compiler/testData/cli/jvm/jspecifyByLv16.args"); + } + @TestMetadata("jspecifyDefault.args") public void testJspecifyDefault() throws Exception { runTest("compiler/testData/cli/jvm/jspecifyDefault.args"); diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 27eff4a755c..d6b86882477 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -359,6 +359,8 @@ enum class LanguageVersion(val major: Int, val minor: Int) : DescriptionAware { fun LanguageVersion.isStableOrReadyForPreview(): Boolean = isStable || this == KOTLIN_1_5 +fun LanguageVersion.toKotlinVersion() = KotlinVersion(major, minor) + interface LanguageVersionSettings { fun getFeatureSupport(feature: LanguageFeature): LanguageFeature.State diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaNullabilityAnnotationSettings.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaNullabilityAnnotationSettings.kt index eb0012175b0..39663aed6ab 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaNullabilityAnnotationSettings.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaNullabilityAnnotationSettings.kt @@ -44,17 +44,18 @@ val nullabilityAnnotationSettings = mapOf( ), ) -private val jsr305Settings = JavaNullabilityAnnotationsStatus( +private val JSR_305_DEFAULT_SETTINGS = JavaNullabilityAnnotationsStatus( reportLevelBefore = ReportLevel.WARN, sinceVersion = null ) -fun getDefaultJsr305Settings(): Jsr305Settings { - val globalReportLevel = if (jsr305Settings.sinceVersion != null && jsr305Settings.sinceVersion <= KotlinVersion.CURRENT) { - jsr305Settings.reportLevelAfter - } else { - jsr305Settings.reportLevelBefore - } +fun getDefaultJsr305Settings(configuredKotlinVersion: KotlinVersion = KotlinVersion.CURRENT): Jsr305Settings { + val globalReportLevel = + if (JSR_305_DEFAULT_SETTINGS.sinceVersion != null && JSR_305_DEFAULT_SETTINGS.sinceVersion <= configuredKotlinVersion) { + JSR_305_DEFAULT_SETTINGS.reportLevelAfter + } else { + JSR_305_DEFAULT_SETTINGS.reportLevelBefore + } val migrationLevel = getDefaultMigrationJsr305ReportLevelForGivenGlobal(globalReportLevel) return Jsr305Settings(globalReportLevel, migrationLevel) } @@ -64,12 +65,15 @@ fun getDefaultMigrationJsr305ReportLevelForGivenGlobal(globalReportLevel: Report fun getDefaultReportLevelForAnnotation(annotationFqName: FqName) = getReportLevelForAnnotation(annotationFqName, emptyMap()) -fun getReportLevelForAnnotation(annotation: FqName, configuredReportLevels: Map): ReportLevel { +fun getReportLevelForAnnotation( + annotation: FqName, configuredReportLevels: Map, + configuredKotlinVersion: KotlinVersion = KotlinVersion.CURRENT +): ReportLevel { annotation.findValueForMostSpecificFqname(configuredReportLevels)?.let { return it } val defaultReportLevel = annotation.findValueForMostSpecificFqname(nullabilityAnnotationSettings) ?: return ReportLevel.IGNORE - return if (defaultReportLevel.sinceVersion != null && defaultReportLevel.sinceVersion <= KotlinVersion.CURRENT) { + return if (defaultReportLevel.sinceVersion != null && defaultReportLevel.sinceVersion <= configuredKotlinVersion) { defaultReportLevel.reportLevelAfter } else { defaultReportLevel.reportLevelBefore diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaTypeEnhancementState.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaTypeEnhancementState.kt index 367c895bb1e..5bfad39f5db 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaTypeEnhancementState.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaTypeEnhancementState.kt @@ -8,12 +8,12 @@ package org.jetbrains.kotlin.load.java import org.jetbrains.kotlin.name.FqName class JavaTypeEnhancementState( - val jsr305: Jsr305Settings = Jsr305Settings.DEFAULT, - val getReportLevelForAnnotation: (FqName) -> ReportLevel = ::getDefaultReportLevelForAnnotation + val jsr305: Jsr305Settings, + val getReportLevelForAnnotation: (FqName) -> ReportLevel ) { val disabledDefaultAnnotations = jsr305.isDisabled || getReportLevelForAnnotation(JSPECIFY_ANNOTATIONS_PACKAGE) == ReportLevel.IGNORE companion object { - val DEFAULT = JavaTypeEnhancementState() + val DEFAULT = JavaTypeEnhancementState(getDefaultJsr305Settings(), ::getDefaultReportLevelForAnnotation) } } diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/Jsr305Settings.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/Jsr305Settings.kt index aa2af4da3aa..8f7dd4dc8db 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/Jsr305Settings.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/Jsr305Settings.kt @@ -12,10 +12,6 @@ data class Jsr305Settings( val migrationLevel: ReportLevel? = null, val userDefinedLevelForSpecificAnnotation: Map = emptyMap() ) { - companion object { - val DEFAULT = getDefaultJsr305Settings() - } - @OptIn(ExperimentalStdlibApi::class) val description by lazy { buildList { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IDELanguageSettingsProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IDELanguageSettingsProvider.kt index be859e4a9ab..a92b10f445e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IDELanguageSettingsProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IDELanguageSettingsProvider.kt @@ -75,11 +75,13 @@ object IDELanguageSettingsProvider : LanguageSettingsProvider { for (module in ModuleManager.getInstance(project).modules) { val settings = KotlinFacetSettingsProvider.getInstance(project)?.getSettings(module) ?: continue val compilerArguments = settings.mergedCompilerArguments as? K2JVMCompilerArguments ?: continue + val kotlinVersion = settings.languageLevel?.toKotlinVersion() ?: KotlinVersion.CURRENT - result = JavaTypeEnhancementStateParser(MessageCollector.NONE).parse( + result = JavaTypeEnhancementStateParser(MessageCollector.NONE, kotlinVersion).parse( compilerArguments.jsr305, compilerArguments.supportCompatqualCheckerFrameworkAnnotations, - compilerArguments.jspecifyAnnotations + compilerArguments.jspecifyAnnotations, + compilerArguments.nullabilityAnnotations ) }