From 7c2fa3290eb5301a1d361ee3ec702fc8afbf4820 Mon Sep 17 00:00:00 2001 From: Svyatoslav Kuzmich Date: Wed, 19 Apr 2023 15:27:35 +0200 Subject: [PATCH] [Wasm] Revert removal of some Dynamic functions Deprecate them with ERROR instead to improve compiler messages --- libraries/stdlib/wasm/src/kotlin/Dynamic.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libraries/stdlib/wasm/src/kotlin/Dynamic.kt b/libraries/stdlib/wasm/src/kotlin/Dynamic.kt index a70fed5032b..815c7f5689c 100644 --- a/libraries/stdlib/wasm/src/kotlin/Dynamic.kt +++ b/libraries/stdlib/wasm/src/kotlin/Dynamic.kt @@ -13,6 +13,19 @@ package kotlin.js @Deprecated("Use JsAny instead", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("JsAny")) public external interface Dynamic : JsAny +/** + * Reinterprets this value as a value of the Dynamic type. + */ +@Deprecated("If value is a subtype of JsAny, use JsAny instead. Otherwise, use toJsHandle", level = DeprecationLevel.ERROR) +fun Any.asDynamic(): JsAny = this.toJsHandle() + +/** + * Reinterprets this value as a value of the Dynamic type. + */ +@Deprecated("Use toJsString instead", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("this.toJsString()")) +@kotlin.internal.InlineOnly +fun String.asDynamic(): JsString = this.toJsString() + private fun jsThrow(e: JsAny) { js("throw e;") }