From 8e0793091a3e118e0f486f70ce9f74d18143d8f8 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 9 Jul 2021 14:25:58 +0300 Subject: [PATCH] Add @NoInfer to safeAs type This change will force specify type argument of every safeAs call --- .../util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt index 64ea6a00eb1..820ce20ed9f 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt @@ -70,7 +70,8 @@ fun sequenceOfLazyValues(vararg elements: () -> T): Sequence = elements.a fun Pair.swap(): Pair = Pair(second, first) -inline fun Any?.safeAs(): T? = this as? T +@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") +inline fun Any?.safeAs(): @kotlin.internal.NoInfer T? = this as? T inline fun Any?.cast(): T = this as T inline fun Any?.assertedCast(message: () -> String): T = this as? T ?: throw AssertionError(message())