From 12cd9c453005fb15e10d39a27c963744a35fcdee Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Thu, 8 Feb 2024 12:59:40 +0100 Subject: [PATCH] [Gradle, JS] Deprecate only deprecated properties in compiler arguments copy --- .../CommonCompilerArgumentsCopyGenerated.kt | 2 +- .../CommonToolArgumentsCopyGenerated.kt | 2 +- .../K2JSCompilerArgumentsCopyGenerated.kt | 4 +++- .../K2JSDceArgumentsCopyGenerated.kt | 2 +- .../K2JVMCompilerArgumentsCopyGenerated.kt | 2 +- ...2MetadataCompilerArgumentsCopyGenerated.kt | 2 +- .../K2NativeCompilerArgumentsCopyGenerated.kt | 2 +- .../GenerateCompilerArgumentsCopy.kt | 23 ++++++++++++++----- .../config/CompilerSettingsCopyGenerated.kt | 2 +- .../config/JpsPluginSettingsCopyGenerated.kt | 2 +- 10 files changed, 28 insertions(+), 15 deletions(-) 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 c257e4e39ec..c2aee1ecf81 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 @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") +@file:Suppress("unused", "DuplicatedCode") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonToolArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonToolArgumentsCopyGenerated.kt index 542f88ff512..3e30c556b80 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonToolArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonToolArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") +@file:Suppress("unused", "DuplicatedCode") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArgumentsCopyGenerated.kt index e2e50a7f0c3..af02ea83f30 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") +@file:Suppress("unused", "DuplicatedCode") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt @@ -44,12 +44,14 @@ fun copyK2JSCompilerArguments(from: K2JSCompilerArguments, to: K2JSCompilerArgum to.irSafeExternalBooleanDiagnostic = from.irSafeExternalBooleanDiagnostic to.libraries = from.libraries to.main = from.main + @Suppress("DEPRECATION") to.metaInfo = from.metaInfo to.moduleKind = from.moduleKind to.moduleName = from.moduleName to.noStdlib = from.noStdlib to.optimizeGeneratedJs = from.optimizeGeneratedJs to.outputDir = from.outputDir + @Suppress("DEPRECATION") to.outputFile = from.outputFile to.partialLinkageLogLevel = from.partialLinkageLogLevel to.partialLinkageMode = from.partialLinkageMode diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArgumentsCopyGenerated.kt index 4ff37f6b725..e5437efccb3 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") +@file:Suppress("unused", "DuplicatedCode") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArgumentsCopyGenerated.kt index 1832e76f3d2..b5f7336a682 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") +@file:Suppress("unused", "DuplicatedCode") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArgumentsCopyGenerated.kt index 7af3b36446d..b9ac7f83a9d 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") +@file:Suppress("unused", "DuplicatedCode") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2NativeCompilerArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2NativeCompilerArgumentsCopyGenerated.kt index 1bf0c9eec3a..65ae92a369c 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2NativeCompilerArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2NativeCompilerArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") +@file:Suppress("unused", "DuplicatedCode") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt b/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt index 2950869e1a0..e72688e44ea 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt @@ -10,10 +10,9 @@ import org.jetbrains.kotlin.config.CompilerSettings import org.jetbrains.kotlin.config.JpsPluginSettings import org.jetbrains.kotlin.utils.Printer import java.io.File -import kotlin.reflect.KClass -import kotlin.reflect.KClassifier -import kotlin.reflect.KType +import kotlin.reflect.* import kotlin.reflect.full.declaredMemberProperties +import kotlin.reflect.full.hasAnnotation import kotlin.reflect.full.superclasses private val CLASSES_TO_PROCESS: List> = listOf( @@ -52,7 +51,7 @@ private fun generateRec( withPrinterToFile(destDir.resolve(klassName + "CopyGenerated.kt")) { println( """ - @file:Suppress("unused", "DuplicatedCode", "DEPRECATION") + @file:Suppress("unused", "DuplicatedCode") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt @@ -106,12 +105,18 @@ private fun generateRec( val arrayElementType = type.arguments.single().type!! val nullableMarker = if (type.isMarkedNullable) "?" else "" when (arrayElementType.classifier) { - String::class -> println("to.${property.name} = from.${property.name}${nullableMarker}.copyOf()") + String::class -> { + deprecatePropertyIfNecessary(property) + println("to.${property.name} = from.${property.name}${nullableMarker}.copyOf()") + } else -> error("Unsupported array element type $arrayElementType (member '${property.name}' of $fqn)") } } - isSupportedImmutable(type) -> println("to.${property.name} = from.${property.name}") + isSupportedImmutable(type) -> { + deprecatePropertyIfNecessary(property) + println("to.${property.name} = from.${property.name}") + } else -> error("Unsupported type to copy: $type (member '${property.name}' of $fqn)") } @@ -124,6 +129,12 @@ private fun generateRec( } } +private fun Printer.deprecatePropertyIfNecessary(property: KProperty1<*, *>) { + if (property.hasAnnotation()) { + println("@Suppress(\"DEPRECATION\")") + } +} + fun main() { generateCompilerArgumentsCopy(::getPrinterToFile) } \ No newline at end of file diff --git a/jps/jps-common/gen/org/jetbrains/kotlin/config/CompilerSettingsCopyGenerated.kt b/jps/jps-common/gen/org/jetbrains/kotlin/config/CompilerSettingsCopyGenerated.kt index 51d42169db1..3976b678b41 100644 --- a/jps/jps-common/gen/org/jetbrains/kotlin/config/CompilerSettingsCopyGenerated.kt +++ b/jps/jps-common/gen/org/jetbrains/kotlin/config/CompilerSettingsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") +@file:Suppress("unused", "DuplicatedCode") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/jps/jps-common/gen/org/jetbrains/kotlin/config/JpsPluginSettingsCopyGenerated.kt b/jps/jps-common/gen/org/jetbrains/kotlin/config/JpsPluginSettingsCopyGenerated.kt index dd2f9df11fa..890e1ef7c86 100644 --- a/jps/jps-common/gen/org/jetbrains/kotlin/config/JpsPluginSettingsCopyGenerated.kt +++ b/jps/jps-common/gen/org/jetbrains/kotlin/config/JpsPluginSettingsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") +@file:Suppress("unused", "DuplicatedCode") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt