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
This commit is contained in:
Nikita Bobko
2022-03-04 15:12:00 +01:00
committed by Space
parent aaef41cf64
commit f0290d8c98
@@ -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 : Freezable> 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 : Freezable> T.unfrozen(): T = getInstanceWithFreezeStatus(false) as T