From c168a19a588fe78111f43cfa7b34de5d12195bb0 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Wed, 8 Dec 2021 10:05:41 +0100 Subject: [PATCH] Build compiler with -Xjvm-default=all + @JvmDefaultCompatibility when needed --- .../kotlin/common-configuration.gradle.kts | 19 +++++++++++++++++++ compiler/frontend/build.gradle.kts | 4 ---- .../internal/NonStableExtensionPoints.kt | 12 ------------ .../extensions/SyntheticResolveExtension.kt | 4 ---- compiler/plugin-api/build.gradle.kts | 4 ---- .../compiler/plugin/CommandLineProcessor.kt | 1 + .../kotlin/psi/KtImportDirective.java | 6 ------ libraries/scripting/intellij/build.gradle.kts | 2 +- .../intellij/scriptDefinitionProvider.kt | 3 +-- 9 files changed, 22 insertions(+), 33 deletions(-) diff --git a/buildSrc/src/main/kotlin/common-configuration.gradle.kts b/buildSrc/src/main/kotlin/common-configuration.gradle.kts index adb1c4c9ca5..65ddb774e7c 100644 --- a/buildSrc/src/main/kotlin/common-configuration.gradle.kts +++ b/buildSrc/src/main/kotlin/common-configuration.gradle.kts @@ -190,6 +190,25 @@ fun Project.configureKotlinCompilationOptions() { if (project.path in projectsWithEnabledContextReceivers) { freeCompilerArgs += "-Xcontext-receivers" } + + //TODO: migrate modules to defaults + //TODO: different gradle versions bundle different Kotlin compilers, not all of them support defaults + if (!project.path.contains("-gradle") && + !project.path.contains("kotlin-project-model") && + !project.path.contains(":binary-compatibility-validator") && + !project.path.contains("runtime") && + //TODO: tune performance in tree and tree.impl modules + !project.path.contains(":compiler:ir.tree") && + //HACK: filter modules with JVM target 1.6 + //TODO: remove after removing 1.6 target + !project.path.startsWith(":core") && + !project.path.startsWith(":kotlin-stdlib") && + !project.path.startsWith(":kotlinx-metadata") && + !project.path.startsWith(":kotlin-scripting") && + !project.path.startsWith(":compiler:tests-common-jvm6") + ) { + freeCompilerArgs += "-Xjvm-default=all" + } } } } diff --git a/compiler/frontend/build.gradle.kts b/compiler/frontend/build.gradle.kts index 8af03b4438c..a1e73baa30b 100644 --- a/compiler/frontend/build.gradle.kts +++ b/compiler/frontend/build.gradle.kts @@ -24,8 +24,4 @@ dependencies { sourceSets { "main" { projectDefault() } "test" {} -} - -tasks.withType().configureEach { - kotlinOptions.freeCompilerArgs += "-Xjvm-default=compatibility" } \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/extensions/internal/NonStableExtensionPoints.kt b/compiler/frontend/src/org/jetbrains/kotlin/extensions/internal/NonStableExtensionPoints.kt index c3beb37b508..f0f6047cf27 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/extensions/internal/NonStableExtensionPoints.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/extensions/internal/NonStableExtensionPoints.kt @@ -55,8 +55,6 @@ interface TypeResolutionInterceptorExtension { @InternalNonStableExtensionPoints interface CallResolutionInterceptorExtension { - @Suppress("DEPRECATION") - @JvmDefault fun interceptResolvedCallAtomCandidate( candidateDescriptor: CallableDescriptor, completedCallAtom: ResolvedCallAtom, @@ -65,8 +63,6 @@ interface CallResolutionInterceptorExtension { diagnostics: Collection ): CallableDescriptor = candidateDescriptor - @Suppress("DEPRECATION") - @JvmDefault fun interceptCandidates( candidates: Collection, context: BasicCallResolutionContext, @@ -77,8 +73,6 @@ interface CallResolutionInterceptorExtension { tracing: TracingStrategy ): Collection = candidates - @Suppress("DEPRECATION") - @JvmDefault fun interceptFunctionCandidates( candidates: Collection, scopeTower: ImplicitScopeTower, @@ -89,8 +83,6 @@ interface CallResolutionInterceptorExtension { location: LookupLocation ): Collection = candidates - @Suppress("DEPRECATION") - @JvmDefault fun interceptFunctionCandidates( candidates: Collection, scopeTower: ImplicitScopeTower, @@ -103,8 +95,6 @@ interface CallResolutionInterceptorExtension { extensionReceiver: ReceiverValueWithSmartCastInfo? ): Collection = candidates - @Suppress("DEPRECATION") - @JvmDefault fun interceptVariableCandidates( candidates: Collection, scopeTower: ImplicitScopeTower, @@ -115,8 +105,6 @@ interface CallResolutionInterceptorExtension { location: LookupLocation ): Collection = candidates - @Suppress("DEPRECATION") - @JvmDefault fun interceptVariableCandidates( candidates: Collection, scopeTower: ImplicitScopeTower, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/extensions/SyntheticResolveExtension.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/extensions/SyntheticResolveExtension.kt index 6577e867d6a..94ba05461d6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/extensions/SyntheticResolveExtension.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/extensions/SyntheticResolveExtension.kt @@ -144,8 +144,6 @@ interface SyntheticResolveExtension { fun getSyntheticFunctionNames(thisDescriptor: ClassDescriptor): List = emptyList() - @Suppress("DEPRECATION") - @JvmDefault fun getSyntheticPropertiesNames(thisDescriptor: ClassDescriptor): List = emptyList() fun getSyntheticNestedClassNames(thisDescriptor: ClassDescriptor): List = emptyList() @@ -155,8 +153,6 @@ interface SyntheticResolveExtension { * or null in case it needs to run resolution and inference and/or it is very costly. * Override this method if resolution started to fail with recursion. */ - @Suppress("DEPRECATION") - @JvmDefault fun getPossibleSyntheticNestedClassNames(thisDescriptor: ClassDescriptor): List? = getSyntheticNestedClassNames(thisDescriptor) fun addSyntheticSupertypes(thisDescriptor: ClassDescriptor, supertypes: MutableList) {} diff --git a/compiler/plugin-api/build.gradle.kts b/compiler/plugin-api/build.gradle.kts index ae55dc27d5f..5cca2f27456 100644 --- a/compiler/plugin-api/build.gradle.kts +++ b/compiler/plugin-api/build.gradle.kts @@ -15,8 +15,4 @@ sourceSets { "test" {} } -tasks.withType().configureEach { - kotlinOptions.freeCompilerArgs += "-Xjvm-default=all-compatibility" -} - optInToExperimentalCompilerApi() diff --git a/compiler/plugin-api/src/org/jetbrains/kotlin/compiler/plugin/CommandLineProcessor.kt b/compiler/plugin-api/src/org/jetbrains/kotlin/compiler/plugin/CommandLineProcessor.kt index 504b3a0ab5b..260aeee5b58 100644 --- a/compiler/plugin-api/src/org/jetbrains/kotlin/compiler/plugin/CommandLineProcessor.kt +++ b/compiler/plugin-api/src/org/jetbrains/kotlin/compiler/plugin/CommandLineProcessor.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.CompilerConfigurationKey @ExperimentalCompilerApi +@JvmDefaultWithCompatibility interface CommandLineProcessor { val pluginId: String val pluginOptions: Collection diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtImportDirective.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtImportDirective.java index 3fdd3d614dc..92fb7f77982 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtImportDirective.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtImportDirective.java @@ -83,12 +83,6 @@ public class KtImportDirective extends KtElementImplStub().configureEach { - kotlinOptions.freeCompilerArgs += "-Xjvm-default=compatibility" + kotlinOptions.freeCompilerArgs += "-Xjvm-default=all" } \ No newline at end of file diff --git a/libraries/scripting/intellij/src/kotlin/script/experimental/intellij/scriptDefinitionProvider.kt b/libraries/scripting/intellij/src/kotlin/script/experimental/intellij/scriptDefinitionProvider.kt index df41c240b61..bc6f7b90e08 100644 --- a/libraries/scripting/intellij/src/kotlin/script/experimental/intellij/scriptDefinitionProvider.kt +++ b/libraries/scripting/intellij/src/kotlin/script/experimental/intellij/scriptDefinitionProvider.kt @@ -23,6 +23,7 @@ import kotlin.script.experimental.host.ScriptingHostConfiguration * may also remove or add new definitions at this point. * Processed definitions are provided to the scripting support infrastructure. */ +@JvmDefaultWithCompatibility interface ScriptDefinitionsProvider { /** * A display name used to identify particular providers @@ -48,8 +49,6 @@ interface ScriptDefinitionsProvider { /** * The callback to update/add/remove script definitions after loading, if needed */ - @Suppress("DEPRECATION") // To be replaced with -Xjvm-default=all-compatibility. - @JvmDefault fun provideDefinitions( baseHostConfiguration: ScriptingHostConfiguration, loadedScriptDefinitions: List