From 9c38db754e7adee118aedf9042954b913dd4ca31 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Wed, 24 Mar 2021 17:01:36 +0300 Subject: [PATCH] Add compiler flag to enable strict mode for improvements in the type enhancement ^KT-45674 Fixed --- .../cli/common/arguments/K2JVMCompilerArguments.kt | 11 +++++++++++ compiler/testData/cli/jvm/extraHelp.out | 2 ++ 2 files changed, 13 insertions(+) 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