Build compiler with -Xjvm-default=all + @JvmDefaultCompatibility when needed

This commit is contained in:
Mikhael Bogdanov
2021-12-08 10:05:41 +01:00
committed by Alexander Udalov
parent 61d339e8f2
commit c168a19a58
9 changed files with 22 additions and 33 deletions
@@ -190,6 +190,25 @@ fun Project.configureKotlinCompilationOptions() {
if (project.path in projectsWithEnabledContextReceivers) { if (project.path in projectsWithEnabledContextReceivers) {
freeCompilerArgs += "-Xcontext-receivers" 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"
}
} }
} }
} }
-4
View File
@@ -24,8 +24,4 @@ dependencies {
sourceSets { sourceSets {
"main" { projectDefault() } "main" { projectDefault() }
"test" {} "test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.freeCompilerArgs += "-Xjvm-default=compatibility"
} }
@@ -55,8 +55,6 @@ interface TypeResolutionInterceptorExtension {
@InternalNonStableExtensionPoints @InternalNonStableExtensionPoints
interface CallResolutionInterceptorExtension { interface CallResolutionInterceptorExtension {
@Suppress("DEPRECATION")
@JvmDefault
fun interceptResolvedCallAtomCandidate( fun interceptResolvedCallAtomCandidate(
candidateDescriptor: CallableDescriptor, candidateDescriptor: CallableDescriptor,
completedCallAtom: ResolvedCallAtom, completedCallAtom: ResolvedCallAtom,
@@ -65,8 +63,6 @@ interface CallResolutionInterceptorExtension {
diagnostics: Collection<KotlinCallDiagnostic> diagnostics: Collection<KotlinCallDiagnostic>
): CallableDescriptor = candidateDescriptor ): CallableDescriptor = candidateDescriptor
@Suppress("DEPRECATION")
@JvmDefault
fun interceptCandidates( fun interceptCandidates(
candidates: Collection<NewResolutionOldInference.MyCandidate>, candidates: Collection<NewResolutionOldInference.MyCandidate>,
context: BasicCallResolutionContext, context: BasicCallResolutionContext,
@@ -77,8 +73,6 @@ interface CallResolutionInterceptorExtension {
tracing: TracingStrategy tracing: TracingStrategy
): Collection<NewResolutionOldInference.MyCandidate> = candidates ): Collection<NewResolutionOldInference.MyCandidate> = candidates
@Suppress("DEPRECATION")
@JvmDefault
fun interceptFunctionCandidates( fun interceptFunctionCandidates(
candidates: Collection<FunctionDescriptor>, candidates: Collection<FunctionDescriptor>,
scopeTower: ImplicitScopeTower, scopeTower: ImplicitScopeTower,
@@ -89,8 +83,6 @@ interface CallResolutionInterceptorExtension {
location: LookupLocation location: LookupLocation
): Collection<FunctionDescriptor> = candidates ): Collection<FunctionDescriptor> = candidates
@Suppress("DEPRECATION")
@JvmDefault
fun interceptFunctionCandidates( fun interceptFunctionCandidates(
candidates: Collection<FunctionDescriptor>, candidates: Collection<FunctionDescriptor>,
scopeTower: ImplicitScopeTower, scopeTower: ImplicitScopeTower,
@@ -103,8 +95,6 @@ interface CallResolutionInterceptorExtension {
extensionReceiver: ReceiverValueWithSmartCastInfo? extensionReceiver: ReceiverValueWithSmartCastInfo?
): Collection<FunctionDescriptor> = candidates ): Collection<FunctionDescriptor> = candidates
@Suppress("DEPRECATION")
@JvmDefault
fun interceptVariableCandidates( fun interceptVariableCandidates(
candidates: Collection<VariableDescriptor>, candidates: Collection<VariableDescriptor>,
scopeTower: ImplicitScopeTower, scopeTower: ImplicitScopeTower,
@@ -115,8 +105,6 @@ interface CallResolutionInterceptorExtension {
location: LookupLocation location: LookupLocation
): Collection<VariableDescriptor> = candidates ): Collection<VariableDescriptor> = candidates
@Suppress("DEPRECATION")
@JvmDefault
fun interceptVariableCandidates( fun interceptVariableCandidates(
candidates: Collection<VariableDescriptor>, candidates: Collection<VariableDescriptor>,
scopeTower: ImplicitScopeTower, scopeTower: ImplicitScopeTower,
@@ -144,8 +144,6 @@ interface SyntheticResolveExtension {
fun getSyntheticFunctionNames(thisDescriptor: ClassDescriptor): List<Name> = emptyList() fun getSyntheticFunctionNames(thisDescriptor: ClassDescriptor): List<Name> = emptyList()
@Suppress("DEPRECATION")
@JvmDefault
fun getSyntheticPropertiesNames(thisDescriptor: ClassDescriptor): List<Name> = emptyList() fun getSyntheticPropertiesNames(thisDescriptor: ClassDescriptor): List<Name> = emptyList()
fun getSyntheticNestedClassNames(thisDescriptor: ClassDescriptor): List<Name> = emptyList() fun getSyntheticNestedClassNames(thisDescriptor: ClassDescriptor): List<Name> = emptyList()
@@ -155,8 +153,6 @@ interface SyntheticResolveExtension {
* or null in case it needs to run resolution and inference and/or it is very costly. * 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. * Override this method if resolution started to fail with recursion.
*/ */
@Suppress("DEPRECATION")
@JvmDefault
fun getPossibleSyntheticNestedClassNames(thisDescriptor: ClassDescriptor): List<Name>? = getSyntheticNestedClassNames(thisDescriptor) fun getPossibleSyntheticNestedClassNames(thisDescriptor: ClassDescriptor): List<Name>? = getSyntheticNestedClassNames(thisDescriptor)
fun addSyntheticSupertypes(thisDescriptor: ClassDescriptor, supertypes: MutableList<KotlinType>) {} fun addSyntheticSupertypes(thisDescriptor: ClassDescriptor, supertypes: MutableList<KotlinType>) {}
-4
View File
@@ -15,8 +15,4 @@ sourceSets {
"test" {} "test" {}
} }
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.freeCompilerArgs += "-Xjvm-default=all-compatibility"
}
optInToExperimentalCompilerApi() optInToExperimentalCompilerApi()
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.CompilerConfigurationKey import org.jetbrains.kotlin.config.CompilerConfigurationKey
@ExperimentalCompilerApi @ExperimentalCompilerApi
@JvmDefaultWithCompatibility
interface CommandLineProcessor { interface CommandLineProcessor {
val pluginId: String val pluginId: String
val pluginOptions: Collection<AbstractCliOption> val pluginOptions: Collection<AbstractCliOption>
@@ -83,12 +83,6 @@ public class KtImportDirective extends KtElementImplStub<KotlinImportDirectiveSt
return new ImportContent.ExpressionBased(reference); return new ImportContent.ExpressionBased(reference);
} }
@Nullable
@Override
public Name getImportedName() {
return KtImportInfo.DefaultImpls.getImportedName(this);
}
@Override @Override
@Nullable @Nullable
@IfNotParsed @IfNotParsed
@@ -25,5 +25,5 @@ publish()
standardPublicJars() standardPublicJars()
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach { tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.freeCompilerArgs += "-Xjvm-default=compatibility" kotlinOptions.freeCompilerArgs += "-Xjvm-default=all"
} }
@@ -23,6 +23,7 @@ import kotlin.script.experimental.host.ScriptingHostConfiguration
* may also remove or add new definitions at this point. * may also remove or add new definitions at this point.
* Processed definitions are provided to the scripting support infrastructure. * Processed definitions are provided to the scripting support infrastructure.
*/ */
@JvmDefaultWithCompatibility
interface ScriptDefinitionsProvider { interface ScriptDefinitionsProvider {
/** /**
* A display name used to identify particular providers * 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 * 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( fun provideDefinitions(
baseHostConfiguration: ScriptingHostConfiguration, baseHostConfiguration: ScriptingHostConfiguration,
loadedScriptDefinitions: List<ScriptDefinition> loadedScriptDefinitions: List<ScriptDefinition>