From f0290d8c98bfdd7a870e91e486c8b671980fc313 Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Fri, 4 Mar 2022 15:12:00 +0100 Subject: [PATCH] Freezable: fix binary compatibility Intellij API Compatibility Check reports that compatibility was broken for IJ Bazel plugin. This commit fixes this problem. Binary compatibility was broken in 705a2881fab109ab7d3e365255d01e0491b17d6d. Ideally, I'd rename extension functions to names other than "frozen" and "unfrozen" because this would allow keeping source compatibility for Java clients as well. But the new extension functions API has been already released in EAP versions of IDEA, and I don't want change the API back and forth for clients that already migrated to the new API. I wish I knew earlier that this API is used by external plugins --- .../kotlin/cli/common/arguments/Freezable.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/Freezable.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/Freezable.kt index f8f62fa358e..b339b577f50 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/Freezable.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/Freezable.kt @@ -41,9 +41,21 @@ abstract class Freezable { private var frozen: Boolean = false internal fun getInstanceWithFreezeStatus(value: Boolean) = if (value == frozen) this else copyBean(this).apply { frozen = value } + + @Deprecated(level = DeprecationLevel.HIDDEN, message = "Please use type safe extension functions") + fun frozen() = getInstanceWithFreezeStatus(true) + + @Deprecated(level = DeprecationLevel.HIDDEN, message = "Please use type safe extension functions") + fun unfrozen() = getInstanceWithFreezeStatus(false) } -@Suppress("UNCHECKED_CAST") +@Suppress( + "UNCHECKED_CAST", + "EXTENSION_SHADOWED_BY_MEMBER" // It's false positive shadowed warning KT-21598 +) fun T.frozen(): T = getInstanceWithFreezeStatus(true) as T -@Suppress("UNCHECKED_CAST") +@Suppress( + "UNCHECKED_CAST", + "EXTENSION_SHADOWED_BY_MEMBER" // It's false positive shadowed warning KT-21598 +) fun T.unfrozen(): T = getInstanceWithFreezeStatus(false) as T