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 4e0ce2ffc1b..10428c2f8aa 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 @@ -471,6 +471,14 @@ default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise"" ) var suppressDeprecatedJvmTargetWarning: Boolean by FreezableVar(false) + @Argument( + value = "-Xtype-enhancement-improvements-strict-mode", + description = "Enable strict mode for some improvements in the type enhancement for loaded Java types based on nullability annotations," + + "including freshly supported reading of the type use annotations from class files. " + + "See KT-45671 for more details" + ) + var typeEnhancementImprovementsInStrictMode: Boolean by FreezableVar(false) + override fun configureAnalysisFlags(collector: MessageCollector): MutableMap, Any> { val result = super.configureAnalysisFlags(collector) result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics @@ -502,6 +510,9 @@ default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise"" if (strictJavaNullabilityAssertions) { result[LanguageFeature.StrictJavaNullabilityAssertions] = LanguageFeature.State.ENABLED } + if (typeEnhancementImprovementsInStrictMode) { + result[LanguageFeature.TypeEnhancementImprovementsInStrictMode] = LanguageFeature.State.ENABLED + } return result } diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index 323e5c2a4cd..184d830eb66 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -126,6 +126,8 @@ where advanced options include: Suppress deprecation warning about deprecated JVM target versions -Xsuppress-missing-builtins-error Suppress the "cannot access built-in declaration" error (useful with -no-stdlib) + -Xtype-enhancement-improvements-strict-mode + Enable strict mode for some improvements in the type enhancement for loaded Java types based on nullability annotations,including freshly supported reading of the type use annotations from class files. See KT-45671 for more details -Xuse-ir Use the IR backend. This option has no effect unless the language version less than 1.5 is used -Xuse-javac Use javac for Java source and class files analysis -Xuse-old-backend Use the old JVM backend