From 9d5e1bdc4751c8b39d698bb35958aaa949e57796 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 24 Oct 2023 12:17:02 +0200 Subject: [PATCH] CLI: remove obsolete -Xallow-result-return-type --- .../arguments/CommonCompilerArgumentsCopyGenerated.kt | 1 - .../cli/common/arguments/CommonCompilerArguments.kt | 11 ----------- .../src/org/jetbrains/kotlin/config/AnalysisFlags.kt | 3 --- .../checkers/ResultClassInReturnTypeChecker.kt | 3 --- .../test/builders/LanguageVersionSettingsBuilder.kt | 3 +-- .../test/directives/LanguageSettingsDirectives.kt | 9 ++++----- compiler/testData/cli/js/jsExtraHelp.out | 1 - compiler/testData/cli/jvm/extraHelp.out | 1 - .../cli/jvm/flagAllowingResultAsReturnType.args | 4 ---- .../cli/jvm/flagAllowingResultAsReturnType.kt | 1 - .../cli/jvm/flagAllowingResultAsReturnType.out | 1 - .../coroutines/allowResultInReturnTypeWithFlag.kt | 1 - .../checkers/CompilerTestLanguageVersionSettings.kt | 2 -- .../org/jetbrains/kotlin/cli/CliTestGenerated.java | 5 ----- .../test/CompilerArgumentsContentProspectorTest.kt | 1 - .../jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt | 2 -- 16 files changed, 5 insertions(+), 44 deletions(-) delete mode 100644 compiler/testData/cli/jvm/flagAllowingResultAsReturnType.args delete mode 100644 compiler/testData/cli/jvm/flagAllowingResultAsReturnType.kt delete mode 100644 compiler/testData/cli/jvm/flagAllowingResultAsReturnType.out diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArgumentsCopyGenerated.kt index 2719ee3ed61..772cd1eef98 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArgumentsCopyGenerated.kt @@ -12,7 +12,6 @@ fun copyCommonCompilerArguments(from: CommonCompilerArguments, to: CommonCompile to.allowAnyScriptsInSourceRoots = from.allowAnyScriptsInSourceRoots to.allowKotlinPackage = from.allowKotlinPackage - to.allowResultReturnType = from.allowResultReturnType to.apiVersion = from.apiVersion to.autoAdvanceApiVersion = from.autoAdvanceApiVersion to.autoAdvanceLanguageVersion = from.autoAdvanceLanguageVersion 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 f968fe8a627..e0be0b737ac 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 @@ -341,16 +341,6 @@ They should be a subset of sources passed as free arguments.""" field = value } - @Argument( - value = "-Xallow-result-return-type", - description = "Allow compiling code when 'kotlin.Result' is used as a return type." - ) - var allowResultReturnType = false - set(value) { - checkFrozen() - field = value - } - @Argument( value = "-Xlist-phases", description = "List backend phases." @@ -810,7 +800,6 @@ The corresponding calls' declarations may not be marked with @BuilderInference." put(AnalysisFlags.optIn, useExperimentalFqNames + optIn?.toList().orEmpty()) put(AnalysisFlags.skipExpectedActualDeclarationChecker, metadataKlib) put(AnalysisFlags.explicitApiVersion, apiVersion != null) - put(AnalysisFlags.allowResultReturnType, allowResultReturnType) ExplicitApiMode.fromString(explicitApi)?.also { put(AnalysisFlags.explicitApiMode, it) } ?: collector.report( CompilerMessageSeverity.ERROR, "Unknown value for parameter -Xexplicit-api: '$explicitApi'. Value should be one of ${ExplicitApiMode.availableValues()}" diff --git a/compiler/config/src/org/jetbrains/kotlin/config/AnalysisFlags.kt b/compiler/config/src/org/jetbrains/kotlin/config/AnalysisFlags.kt index bc23e47f7e1..dda5a50eaa1 100644 --- a/compiler/config/src/org/jetbrains/kotlin/config/AnalysisFlags.kt +++ b/compiler/config/src/org/jetbrains/kotlin/config/AnalysisFlags.kt @@ -30,9 +30,6 @@ object AnalysisFlags { @JvmStatic val ignoreDataFlowInAssert by AnalysisFlag.Delegates.Boolean - @JvmStatic - val allowResultReturnType by AnalysisFlag.Delegates.Boolean - @JvmStatic val explicitApiMode by AnalysisFlag.Delegates.ApiModeDisabledByDefault diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ResultClassInReturnTypeChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ResultClassInReturnTypeChecker.kt index 5d392ecc55c..9f4efb16acc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ResultClassInReturnTypeChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ResultClassInReturnTypeChecker.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.resolve.checkers import org.jetbrains.kotlin.builtins.StandardNames -import org.jetbrains.kotlin.config.AnalysisFlags import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.diagnostics.Errors @@ -20,8 +19,6 @@ class ResultClassInReturnTypeChecker : DeclarationChecker { override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { val languageVersionSettings = context.languageVersionSettings - if (languageVersionSettings.getFlag(AnalysisFlags.allowResultReturnType)) return - if ((languageVersionSettings.getFeatureSupport(LanguageFeature.InlineClasses) == LanguageFeature.State.ENABLED || languageVersionSettings.supportsFeature(LanguageFeature.JvmInlineValueClasses)) && languageVersionSettings.supportsFeature(LanguageFeature.AllowResultInReturnType) 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 8de0e1cd179..2c9dd6a1ba4 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 @@ -10,8 +10,8 @@ import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives import org.jetbrains.kotlin.test.directives.model.singleOrZeroValue -import org.jetbrains.kotlin.test.services.DefaultsDsl import org.jetbrains.kotlin.test.services.AbstractEnvironmentConfigurator +import org.jetbrains.kotlin.test.services.DefaultsDsl import org.jetbrains.kotlin.test.util.LANGUAGE_FEATURE_PATTERN import org.jetbrains.kotlin.utils.addToStdlib.runIf @@ -100,7 +100,6 @@ class LanguageVersionSettingsBuilder { val analysisFlags = listOfNotNull( analysisFlag(AnalysisFlags.optIn, directives[LanguageSettingsDirectives.OPT_IN].takeIf { it.isNotEmpty() }), analysisFlag(AnalysisFlags.ignoreDataFlowInAssert, trueOrNull(LanguageSettingsDirectives.IGNORE_DATA_FLOW_IN_ASSERT in directives)), - analysisFlag(AnalysisFlags.allowResultReturnType, trueOrNull(LanguageSettingsDirectives.ALLOW_RESULT_RETURN_TYPE in directives)), analysisFlag(AnalysisFlags.explicitApiMode, directives.singleOrZeroValue(LanguageSettingsDirectives.EXPLICIT_API_MODE)), analysisFlag(AnalysisFlags.allowKotlinPackage, trueOrNull(LanguageSettingsDirectives.ALLOW_KOTLIN_PACKAGE in directives)), analysisFlag(AnalysisFlags.muteExpectActualClassesWarning, trueOrNull(LanguageSettingsDirectives.ENABLE_EXPECT_ACTUAL_CLASSES_WARNING in directives) != true), diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/LanguageSettingsDirectives.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/LanguageSettingsDirectives.kt index ce152fde12e..ec247f82999 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/LanguageSettingsDirectives.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/LanguageSettingsDirectives.kt @@ -5,7 +5,10 @@ package org.jetbrains.kotlin.test.directives -import org.jetbrains.kotlin.config.* +import org.jetbrains.kotlin.config.ApiVersion +import org.jetbrains.kotlin.config.ExplicitApiMode +import org.jetbrains.kotlin.config.JvmDefaultMode +import org.jetbrains.kotlin.config.LanguageVersion import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer object LanguageSettingsDirectives : SimpleDirectivesContainer() { @@ -51,10 +54,6 @@ object LanguageSettingsDirectives : SimpleDirectivesContainer() { description = "Enables corresponding analysis flag (AnalysisFlags.ignoreDataFlowInAssert)" ) - val ALLOW_RESULT_RETURN_TYPE by directive( - description = "Allow using Result in return type position" - ) - val EXPLICIT_API_MODE by enumDirective( "Configures explicit API mode (AnalysisFlags.explicitApiMode)", additionalParser = ExplicitApiMode.Companion::fromString diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index 2220b889b4f..b32cc7f49bd 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -68,7 +68,6 @@ where advanced options include: -Xallow-any-scripts-in-source-roots Allow compiling scripts along with regular Kotlin sources. -Xallow-kotlin-package Allow compiling code in the 'kotlin' package, and allow not requiring 'kotlin.stdlib' in 'module-info'. - -Xallow-result-return-type Allow compiling code when 'kotlin.Result' is used as a return type. -Xbuiltins-from-sources Compile built-ins from sources. -Xcheck-phase-conditions Check pre- and postconditions of IR lowering phases. -Xcheck-sticky-phase-conditions diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index 9cf9b4e826b..f4a928ddf0c 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -155,7 +155,6 @@ where advanced options include: -Xallow-any-scripts-in-source-roots Allow compiling scripts along with regular Kotlin sources. -Xallow-kotlin-package Allow compiling code in the 'kotlin' package, and allow not requiring 'kotlin.stdlib' in 'module-info'. - -Xallow-result-return-type Allow compiling code when 'kotlin.Result' is used as a return type. -Xbuiltins-from-sources Compile built-ins from sources. -Xcheck-phase-conditions Check pre- and postconditions of IR lowering phases. -Xcheck-sticky-phase-conditions diff --git a/compiler/testData/cli/jvm/flagAllowingResultAsReturnType.args b/compiler/testData/cli/jvm/flagAllowingResultAsReturnType.args deleted file mode 100644 index a79300a6a43..00000000000 --- a/compiler/testData/cli/jvm/flagAllowingResultAsReturnType.args +++ /dev/null @@ -1,4 +0,0 @@ -$TESTDATA_DIR$/flagAllowingResultAsReturnType.kt --Xallow-result-return-type --d -$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/flagAllowingResultAsReturnType.kt b/compiler/testData/cli/jvm/flagAllowingResultAsReturnType.kt deleted file mode 100644 index 7d0238befc6..00000000000 --- a/compiler/testData/cli/jvm/flagAllowingResultAsReturnType.kt +++ /dev/null @@ -1 +0,0 @@ -fun foo(): Result = TODO() \ No newline at end of file diff --git a/compiler/testData/cli/jvm/flagAllowingResultAsReturnType.out b/compiler/testData/cli/jvm/flagAllowingResultAsReturnType.out deleted file mode 100644 index a0aba9318ad..00000000000 --- a/compiler/testData/cli/jvm/flagAllowingResultAsReturnType.out +++ /dev/null @@ -1 +0,0 @@ -OK \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/allowResultInReturnTypeWithFlag.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/allowResultInReturnTypeWithFlag.kt index ea7e4144eb6..62ea6688f96 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/allowResultInReturnTypeWithFlag.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/allowResultInReturnTypeWithFlag.kt @@ -1,5 +1,4 @@ // FIR_IDENTICAL -// !ALLOW_RESULT_RETURN_TYPE // !LANGUAGE: -AllowNullOperatorsForResult fun result(): Result = TODO() diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/CompilerTestLanguageVersionSettings.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/CompilerTestLanguageVersionSettings.kt index e9021e43350..be2d42a7565 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/CompilerTestLanguageVersionSettings.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/CompilerTestLanguageVersionSettings.kt @@ -20,7 +20,6 @@ const val OPT_IN_DIRECTIVE = "OPT_IN" const val IGNORE_DATA_FLOW_IN_ASSERT_DIRECTIVE = "IGNORE_DATA_FLOW_IN_ASSERT" const val JVM_DEFAULT_MODE = "JVM_DEFAULT_MODE" const val SKIP_METADATA_VERSION_CHECK = "SKIP_METADATA_VERSION_CHECK" -const val ALLOW_RESULT_RETURN_TYPE = "ALLOW_RESULT_RETURN_TYPE" const val INHERIT_MULTIFILE_PARTS = "INHERIT_MULTIFILE_PARTS" const val SANITIZE_PARENTHESES = "SANITIZE_PARENTHESES" const val ENABLE_JVM_PREVIEW = "ENABLE_JVM_PREVIEW" @@ -66,7 +65,6 @@ fun parseLanguageVersionSettings( analysisFlag(JvmAnalysisFlags.jvmDefaultMode, directives[JVM_DEFAULT_MODE]?.let { JvmDefaultMode.fromStringOrNull(it) }), analysisFlag(AnalysisFlags.ignoreDataFlowInAssert, if (IGNORE_DATA_FLOW_IN_ASSERT_DIRECTIVE in directives) true else null), analysisFlag(AnalysisFlags.skipMetadataVersionCheck, if (SKIP_METADATA_VERSION_CHECK in directives) true else null), - analysisFlag(AnalysisFlags.allowResultReturnType, if (ALLOW_RESULT_RETURN_TYPE in directives) true else null), analysisFlag(JvmAnalysisFlags.inheritMultifileParts, if (INHERIT_MULTIFILE_PARTS in directives) true else null), analysisFlag(JvmAnalysisFlags.sanitizeParentheses, if (SANITIZE_PARENTHESES in directives) true else null), analysisFlag(JvmAnalysisFlags.enableJvmPreview, if (ENABLE_JVM_PREVIEW in directives) true else null), diff --git a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java index dcc10685e58..c6b0ed9cde6 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java @@ -630,11 +630,6 @@ public class CliTestGenerated extends AbstractCliTest { runTest("compiler/testData/cli/jvm/firVsClassicAnnotation.args"); } - @TestMetadata("flagAllowingResultAsReturnType.args") - public void testFlagAllowingResultAsReturnType() throws Exception { - runTest("compiler/testData/cli/jvm/flagAllowingResultAsReturnType.args"); - } - @TestMetadata("forbidKotlinPackageK1.args") public void testForbidKotlinPackageK1() throws Exception { runTest("compiler/testData/cli/jvm/forbidKotlinPackageK1.args"); diff --git a/jps/jps-common/test/CompilerArgumentsContentProspectorTest.kt b/jps/jps-common/test/CompilerArgumentsContentProspectorTest.kt index 266bf3c581f..ab13d89a67e 100644 --- a/jps/jps-common/test/CompilerArgumentsContentProspectorTest.kt +++ b/jps/jps-common/test/CompilerArgumentsContentProspectorTest.kt @@ -93,7 +93,6 @@ class CompilerArgumentsContentProspectorTest { CommonCompilerArguments::readDeserializedContracts, CommonCompilerArguments::properIeee754Comparisons, CommonCompilerArguments::reportPerf, - CommonCompilerArguments::allowResultReturnType, CommonCompilerArguments::listPhases, CommonCompilerArguments::profilePhases, CommonCompilerArguments::checkPhaseConditions, diff --git a/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt b/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt index 4fb440990fd..2e481601666 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt @@ -95,7 +95,6 @@ class GenerateIrRuntime { "kotlin.Experimental", "kotlin.ExperimentalMultiplatform" ), - AnalysisFlags.allowResultReturnType to true ) ) @@ -307,7 +306,6 @@ class GenerateIrRuntime { irModuleName = "kotlin" allowKotlinPackage = true optIn = arrayOf("kotlin.contracts.ExperimentalContracts", "kotlin.Experimental", "kotlin.ExperimentalMultiplatform") - allowResultReturnType = true multiPlatform = true languageVersion = "1.4" commonSources = filesToCompile.filter { it.isCommonSource == true }.map { it.virtualFilePath }.toTypedArray()