[KLIB] Deprecate -Xexpect-actual-linker CLI argument
This argument has been finally superseded by `-Xmetadata-klib`. ^KT-61136
This commit is contained in:
committed by
Space Team
parent
620c9434ca
commit
78a962f6d2
-1
@@ -32,7 +32,6 @@ fun copyCommonCompilerArguments(from: CommonCompilerArguments, to: CommonCompile
|
|||||||
to.enableBuilderInference = from.enableBuilderInference
|
to.enableBuilderInference = from.enableBuilderInference
|
||||||
to.enableSignatureClashChecks = from.enableSignatureClashChecks
|
to.enableSignatureClashChecks = from.enableSignatureClashChecks
|
||||||
to.expectActualClasses = from.expectActualClasses
|
to.expectActualClasses = from.expectActualClasses
|
||||||
to.expectActualLinker = from.expectActualLinker
|
|
||||||
to.experimental = from.experimental?.copyOf()
|
to.experimental = from.experimental?.copyOf()
|
||||||
to.explicitApi = from.explicitApi
|
to.explicitApi = from.explicitApi
|
||||||
to.extendedCompilerChecks = from.extendedCompilerChecks
|
to.extendedCompilerChecks = from.extendedCompilerChecks
|
||||||
|
|||||||
+3
-13
@@ -574,7 +574,8 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
|
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-Xmetadata-klib",
|
value = "-Xmetadata-klib",
|
||||||
description = "Produce a klib that only contains the declarations metadata"
|
description = "Produce a klib that only contains the declarations metadata",
|
||||||
|
deprecatedName = "-Xexpect-actual-linker"
|
||||||
)
|
)
|
||||||
var metadataKlib: Boolean = false
|
var metadataKlib: Boolean = false
|
||||||
set(value) {
|
set(value) {
|
||||||
@@ -582,17 +583,6 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
/** TODO: replace by [metadataKlib] */
|
|
||||||
@Argument(
|
|
||||||
value = "-Xexpect-actual-linker",
|
|
||||||
description = "Enable experimental expect/actual linker"
|
|
||||||
)
|
|
||||||
var expectActualLinker = false
|
|
||||||
set(value) {
|
|
||||||
checkFrozen()
|
|
||||||
field = value
|
|
||||||
}
|
|
||||||
|
|
||||||
@Argument(value = "-Xdisable-default-scripting-plugin", description = "Do not enable scripting plugin by default")
|
@Argument(value = "-Xdisable-default-scripting-plugin", description = "Do not enable scripting plugin by default")
|
||||||
var disableDefaultScriptingPlugin = false
|
var disableDefaultScriptingPlugin = false
|
||||||
set(value) {
|
set(value) {
|
||||||
@@ -818,7 +808,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
put(AnalysisFlags.optIn, useExperimentalFqNames + optIn?.toList().orEmpty())
|
put(AnalysisFlags.optIn, useExperimentalFqNames + optIn?.toList().orEmpty())
|
||||||
put(AnalysisFlags.skipExpectedActualDeclarationChecker, expectActualLinker || metadataKlib) // TODO (KT-61136): drop `expectActualLinker` later, after the appropriate changes in the Gradle plugin
|
put(AnalysisFlags.skipExpectedActualDeclarationChecker, metadataKlib)
|
||||||
put(AnalysisFlags.explicitApiVersion, apiVersion != null)
|
put(AnalysisFlags.explicitApiVersion, apiVersion != null)
|
||||||
put(AnalysisFlags.allowResultReturnType, allowResultReturnType)
|
put(AnalysisFlags.allowResultReturnType, allowResultReturnType)
|
||||||
ExplicitApiMode.fromString(explicitApi)?.also { put(AnalysisFlags.explicitApiMode, it) } ?: collector.report(
|
ExplicitApiMode.fromString(explicitApi)?.also { put(AnalysisFlags.explicitApiMode, it) } ?: collector.report(
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ fun CompilerConfiguration.setupCommonArguments(
|
|||||||
|
|
||||||
put(CommonConfigurationKeys.DISABLE_INLINE, arguments.noInline)
|
put(CommonConfigurationKeys.DISABLE_INLINE, arguments.noInline)
|
||||||
put(CommonConfigurationKeys.USE_FIR_EXTENDED_CHECKERS, arguments.useFirExtendedCheckers)
|
put(CommonConfigurationKeys.USE_FIR_EXTENDED_CHECKERS, arguments.useFirExtendedCheckers)
|
||||||
put(CommonConfigurationKeys.EXPECT_ACTUAL_LINKER, arguments.expectActualLinker)
|
|
||||||
put(CommonConfigurationKeys.METADATA_KLIB, arguments.metadataKlib)
|
put(CommonConfigurationKeys.METADATA_KLIB, arguments.metadataKlib)
|
||||||
putIfNotNull(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, arguments.intellijPluginRoot)
|
putIfNotNull(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, arguments.intellijPluginRoot)
|
||||||
put(CommonConfigurationKeys.REPORT_OUTPUT_FILES, arguments.reportOutputFiles)
|
put(CommonConfigurationKeys.REPORT_OUTPUT_FILES, arguments.reportOutputFiles)
|
||||||
|
|||||||
@@ -101,8 +101,7 @@ class K2MetadataCompiler : CLICompiler<K2MetadataCompilerArguments>() {
|
|||||||
val environment =
|
val environment =
|
||||||
KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.METADATA_CONFIG_FILES)
|
KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.METADATA_CONFIG_FILES)
|
||||||
|
|
||||||
// TODO (KT-61136): drop `expectActualLinker` later, after the appropriate changes in the Gradle plugin
|
val mode = if (arguments.metadataKlib) "KLib" else "metadata"
|
||||||
val mode = if (arguments.expectActualLinker || arguments.metadataKlib) "KLib" else "metadata"
|
|
||||||
|
|
||||||
val sourceFiles = environment.getSourceFiles()
|
val sourceFiles = environment.getSourceFiles()
|
||||||
performanceManager.notifyCompilerInitialized(sourceFiles.size, environment.countLinesOfCode(sourceFiles), "$mode mode for $moduleName module")
|
performanceManager.notifyCompilerInitialized(sourceFiles.size, environment.countLinesOfCode(sourceFiles), "$mode mode for $moduleName module")
|
||||||
@@ -121,8 +120,7 @@ class K2MetadataCompiler : CLICompiler<K2MetadataCompilerArguments>() {
|
|||||||
val useFir = configuration.getBoolean(CommonConfigurationKeys.USE_FIR)
|
val useFir = configuration.getBoolean(CommonConfigurationKeys.USE_FIR)
|
||||||
val metadataSerializer = when {
|
val metadataSerializer = when {
|
||||||
useFir -> FirMetadataSerializer(configuration, environment)
|
useFir -> FirMetadataSerializer(configuration, environment)
|
||||||
// TODO (KT-61136): drop `expectActualLinker` later, after the appropriate changes in the Gradle plugin
|
arguments.metadataKlib -> K2MetadataKlibSerializer(configuration, environment)
|
||||||
arguments.expectActualLinker || arguments.metadataKlib -> K2MetadataKlibSerializer(configuration, environment)
|
|
||||||
else -> MetadataSerializer(configuration, environment, dependOnOldBuiltIns = true)
|
else -> MetadataSerializer(configuration, environment, dependOnOldBuiltIns = true)
|
||||||
}
|
}
|
||||||
metadataSerializer.analyzeAndSerialize()
|
metadataSerializer.analyzeAndSerialize()
|
||||||
|
|||||||
@@ -60,9 +60,6 @@ object CommonConfigurationKeys {
|
|||||||
@JvmField
|
@JvmField
|
||||||
val HMPP_MODULE_STRUCTURE = CompilerConfigurationKey.create<HmppCliModuleStructure>("HMPP module structure")
|
val HMPP_MODULE_STRUCTURE = CompilerConfigurationKey.create<HmppCliModuleStructure>("HMPP module structure")
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val EXPECT_ACTUAL_LINKER = CompilerConfigurationKey.create<Boolean>("Experimental expect/actual linker")
|
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val METADATA_KLIB = CompilerConfigurationKey.create<Boolean>("Produce metadata klib")
|
val METADATA_KLIB = CompilerConfigurationKey.create<Boolean>("Produce metadata klib")
|
||||||
|
|
||||||
|
|||||||
-1
@@ -89,7 +89,6 @@ where advanced options include:
|
|||||||
Enable the checks on uniqueness of signatures
|
Enable the checks on uniqueness of signatures
|
||||||
-Xexpect-actual-classes 'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta.
|
-Xexpect-actual-classes 'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta.
|
||||||
Kotlin reports a warning every time you use them. You can use this flag to mute the warning.
|
Kotlin reports a warning every time you use them. You can use this flag to mute the warning.
|
||||||
-Xexpect-actual-linker Enable experimental expect/actual linker
|
|
||||||
-Xexplicit-api={strict|warning|disable}
|
-Xexplicit-api={strict|warning|disable}
|
||||||
Force compiler to report errors on all public API declarations without explicit visibility or return type.
|
Force compiler to report errors on all public API declarations without explicit visibility or return type.
|
||||||
Use 'warning' level to issue warnings instead of errors.
|
Use 'warning' level to issue warnings instead of errors.
|
||||||
|
|||||||
-1
@@ -180,7 +180,6 @@ where advanced options include:
|
|||||||
Enable the checks on uniqueness of signatures
|
Enable the checks on uniqueness of signatures
|
||||||
-Xexpect-actual-classes 'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta.
|
-Xexpect-actual-classes 'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta.
|
||||||
Kotlin reports a warning every time you use them. You can use this flag to mute the warning.
|
Kotlin reports a warning every time you use them. You can use this flag to mute the warning.
|
||||||
-Xexpect-actual-linker Enable experimental expect/actual linker
|
|
||||||
-Xexplicit-api={strict|warning|disable}
|
-Xexplicit-api={strict|warning|disable}
|
||||||
Force compiler to report errors on all public API declarations without explicit visibility or return type.
|
Force compiler to report errors on all public API declarations without explicit visibility or return type.
|
||||||
Use 'warning' level to issue warnings instead of errors.
|
Use 'warning' level to issue warnings instead of errors.
|
||||||
|
|||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import lib.*
|
||||||
|
|
||||||
|
val w = W()
|
||||||
|
val v1 = fn()
|
||||||
|
val v2 = O.o()
|
||||||
|
val v3 = w.w()
|
||||||
|
|
||||||
|
// private
|
||||||
|
val e1 = o3
|
||||||
|
val e2 = w.o7
|
||||||
|
val e3 = O.o10
|
||||||
+154
@@ -0,0 +1,154 @@
|
|||||||
|
package lib
|
||||||
|
|
||||||
|
interface I1 {
|
||||||
|
fun i1() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface I2 {
|
||||||
|
fun i2() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface I3 : I2, I1
|
||||||
|
|
||||||
|
open class C {
|
||||||
|
fun c() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class G<T> {
|
||||||
|
fun g() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val o1 = object { fun foo() {} }
|
||||||
|
private val o2 = object : I1 {}
|
||||||
|
private val o3 = object : I1, I2 {}
|
||||||
|
private val o4 = object : I3 {}
|
||||||
|
private val o5 = object : C() {}
|
||||||
|
private val o6 = object : C(), I1, I2 {}
|
||||||
|
private val o7 = object : C(), I3 {}
|
||||||
|
private val o8 = object : G<Int>() {}
|
||||||
|
private val o9 = object : G<Int>(), I1, I2 {}
|
||||||
|
private val o10 = object : G<Int>(), I3 {}
|
||||||
|
|
||||||
|
private val o11 = object {
|
||||||
|
inner class D {
|
||||||
|
fun df() {}
|
||||||
|
}
|
||||||
|
fun d(): D = D()
|
||||||
|
}.d()
|
||||||
|
|
||||||
|
private val o12 = {
|
||||||
|
class L {
|
||||||
|
fun l() {}
|
||||||
|
}
|
||||||
|
L()
|
||||||
|
}()
|
||||||
|
|
||||||
|
private val o13 = {
|
||||||
|
class L {
|
||||||
|
inner class L1 {
|
||||||
|
inner class L2 {
|
||||||
|
fun l2() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
L().L1().L2()
|
||||||
|
}()
|
||||||
|
|
||||||
|
fun fn() {
|
||||||
|
o1.foo()
|
||||||
|
o2.i1()
|
||||||
|
o3.i1()
|
||||||
|
o3.i2()
|
||||||
|
o4.i1()
|
||||||
|
o4.i2()
|
||||||
|
o5.c()
|
||||||
|
o6.c()
|
||||||
|
o6.i1()
|
||||||
|
o6.i2()
|
||||||
|
o7.c()
|
||||||
|
o7.i1()
|
||||||
|
o7.i2()
|
||||||
|
o8.g()
|
||||||
|
o9.g()
|
||||||
|
o9.i1()
|
||||||
|
o9.i2()
|
||||||
|
o10.g()
|
||||||
|
o10.i1()
|
||||||
|
o10.i2()
|
||||||
|
o11.df()
|
||||||
|
o12.l()
|
||||||
|
o13.l2()
|
||||||
|
}
|
||||||
|
|
||||||
|
class W {
|
||||||
|
private val o1 = object { fun foo() {} }
|
||||||
|
private val o2 = object : I1 {}
|
||||||
|
private val o3 = object : I1, I2 {}
|
||||||
|
private val o4 = object : I3 {}
|
||||||
|
private val o5 = object : C() {}
|
||||||
|
private val o6 = object : C(), I1, I2 {}
|
||||||
|
private val o7 = object : C(), I3 {}
|
||||||
|
private val o8 = object : G<Int>() {}
|
||||||
|
private val o9 = object : G<Int>(), I1, I2 {}
|
||||||
|
private val o10 = object : G<Int>(), I3 {}
|
||||||
|
|
||||||
|
fun w() {
|
||||||
|
o1.foo()
|
||||||
|
o2.i1()
|
||||||
|
o3.i1()
|
||||||
|
o3.i2()
|
||||||
|
o4.i1()
|
||||||
|
o4.i2()
|
||||||
|
o5.c()
|
||||||
|
o6.c()
|
||||||
|
o6.i1()
|
||||||
|
o6.i2()
|
||||||
|
o7.c()
|
||||||
|
o7.i1()
|
||||||
|
o7.i2()
|
||||||
|
o8.g()
|
||||||
|
o9.g()
|
||||||
|
o9.i1()
|
||||||
|
o9.i2()
|
||||||
|
o10.g()
|
||||||
|
o10.i1()
|
||||||
|
o10.i2()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object O {
|
||||||
|
private val o1 = object { fun foo() {} }
|
||||||
|
private val o2 = object : I1 {}
|
||||||
|
private val o3 = object : I1, I2 {}
|
||||||
|
private val o4 = object : I3 {}
|
||||||
|
private val o5 = object : C() {}
|
||||||
|
private val o6 = object : C(), I1, I2 {}
|
||||||
|
private val o7 = object : C(), I3 {}
|
||||||
|
private val o8 = object : G<Int>() {}
|
||||||
|
private val o9 = object : G<Int>(), I1, I2 {}
|
||||||
|
private val o10 = object : G<Int>(), I3 {}
|
||||||
|
|
||||||
|
fun o() {
|
||||||
|
o1.foo()
|
||||||
|
o2.i1()
|
||||||
|
o3.i1()
|
||||||
|
o3.i2()
|
||||||
|
o4.i1()
|
||||||
|
o4.i2()
|
||||||
|
o5.c()
|
||||||
|
o6.c()
|
||||||
|
o6.i1()
|
||||||
|
o6.i2()
|
||||||
|
o7.c()
|
||||||
|
o7.i1()
|
||||||
|
o7.i2()
|
||||||
|
o8.g()
|
||||||
|
o9.g()
|
||||||
|
o9.i1()
|
||||||
|
o9.i2()
|
||||||
|
o10.g()
|
||||||
|
o10.i1()
|
||||||
|
o10.i2()
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
warning: argument -Xexpect-actual-linker is deprecated. Please use -Xmetadata-klib instead
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadataKlibWithOldCLIKey/anonymousObjectTypeMetadata.kt:11:10: error: cannot access 'val o3: Any': it is private in file.
|
||||||
|
val e1 = o3
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadataKlibWithOldCLIKey/anonymousObjectTypeMetadata.kt:12:12: error: cannot access 'val o7: Any': it is private in 'lib/W'.
|
||||||
|
val e2 = w.o7
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadataKlibWithOldCLIKey/anonymousObjectTypeMetadata.kt:13:12: error: cannot access 'val o10: Any': it is private in 'lib/O'.
|
||||||
|
val e3 = O.o10
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
warning: argument -Xexpect-actual-linker is deprecated. Please use -Xmetadata-klib instead
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadataKlibWithOldCLIKey/anonymousObjectTypeMetadata.kt:11:10: error: cannot access 'o3': it is private in file
|
||||||
|
val e1 = o3
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadataKlibWithOldCLIKey/anonymousObjectTypeMetadata.kt:12:12: error: cannot access 'o7': it is private in 'W'
|
||||||
|
val e2 = w.o7
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadataKlibWithOldCLIKey/anonymousObjectTypeMetadata.kt:13:12: error: cannot access 'o10': it is private in 'O'
|
||||||
|
val e3 = O.o10
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+24
-15
@@ -706,29 +706,38 @@ abstract class AbstractCompileKotlinAgainstCustomBinariesTest : AbstractKotlinCo
|
|||||||
assertEquals("Output:\n$output", ExitCode.COMPILATION_ERROR, exitCode)
|
assertEquals("Output:\n$output", ExitCode.COMPILATION_ERROR, exitCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testAnonymousObjectTypeMetadata() {
|
fun testAnonymousObjectTypeMetadata() = doTestAnonymousObjectTypeMetadata()
|
||||||
|
|
||||||
|
fun testAnonymousObjectTypeMetadataKlib() = doTestAnonymousObjectTypeMetadata(listOf("-Xmetadata-klib"))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test does exactly the same as [testAnonymousObjectTypeMetadataKlib] but using the old (now deprecated)
|
||||||
|
* CLI argument `-Xexpect-actual-linker` instead of its successor `-Xmetadata-klib`.
|
||||||
|
*
|
||||||
|
* The test is needed only to check that the old CLI argument still works as needed.
|
||||||
|
*/
|
||||||
|
fun testAnonymousObjectTypeMetadataKlibWithOldCLIKey() = doTestAnonymousObjectTypeMetadata(listOf("-Xexpect-actual-linker")) { output ->
|
||||||
|
output.lines().filterNot { "argument -Xexpect-actual-linker is deprecated" in it }.joinToString("\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doTestAnonymousObjectTypeMetadata(
|
||||||
|
extraCommandLineArguments: List<String> = emptyList(),
|
||||||
|
filterOutput: (String) -> String = { output -> output }
|
||||||
|
) {
|
||||||
val library = compileCommonLibrary(
|
val library = compileCommonLibrary(
|
||||||
libraryName = "library",
|
libraryName = "library",
|
||||||
|
additionalOptions = extraCommandLineArguments,
|
||||||
|
checkKotlinOutput = { output ->
|
||||||
|
assertEquals(normalizeOutput("" to ExitCode.OK), filterOutput(output))
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
compileKotlin(
|
compileKotlin(
|
||||||
"anonymousObjectTypeMetadata.kt",
|
"anonymousObjectTypeMetadata.kt",
|
||||||
tmpdir,
|
tmpdir,
|
||||||
listOf(library),
|
listOf(library),
|
||||||
K2MetadataCompiler(),
|
K2MetadataCompiler(),
|
||||||
)
|
additionalOptions = extraCommandLineArguments
|
||||||
}
|
|
||||||
|
|
||||||
fun testAnonymousObjectTypeMetadataKlib() {
|
|
||||||
val klibLibrary = compileCommonLibrary(
|
|
||||||
libraryName = "library",
|
|
||||||
listOf("-Xmetadata-klib"),
|
|
||||||
)
|
|
||||||
compileKotlin(
|
|
||||||
"anonymousObjectTypeMetadata.kt",
|
|
||||||
tmpdir,
|
|
||||||
listOf(klibLibrary),
|
|
||||||
K2MetadataCompiler(),
|
|
||||||
listOf("-Xmetadata-klib")
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ class CompilerArgumentsContentProspectorTest {
|
|||||||
CommonCompilerArguments::disableUltraLightClasses,
|
CommonCompilerArguments::disableUltraLightClasses,
|
||||||
CommonCompilerArguments::useMixedNamedArguments,
|
CommonCompilerArguments::useMixedNamedArguments,
|
||||||
CommonCompilerArguments::metadataKlib,
|
CommonCompilerArguments::metadataKlib,
|
||||||
CommonCompilerArguments::expectActualLinker,
|
|
||||||
CommonCompilerArguments::extendedCompilerChecks,
|
CommonCompilerArguments::extendedCompilerChecks,
|
||||||
CommonCompilerArguments::disableDefaultScriptingPlugin,
|
CommonCompilerArguments::disableDefaultScriptingPlugin,
|
||||||
CommonCompilerArguments::inferenceCompatibility,
|
CommonCompilerArguments::inferenceCompatibility,
|
||||||
|
|||||||
Reference in New Issue
Block a user