[JS IR] add a flag which enable safe property access
If an accessor is not available at runtime we fall back to the property access. This is useful in cases when JS objects are casted to Kotlin classes implicitly. This pattern did work in the old BE, which lead to a significant amount of code which doesn't work anymore.
This commit is contained in:
committed by
TeamCityServer
parent
8b18818bcc
commit
6633a9edc0
@@ -13,6 +13,17 @@ internal fun <T : Enum<T>> enumValuesIntrinsic(): Array<T> =
|
||||
internal fun <T : Enum<T>> enumValueOfIntrinsic(@Suppress("UNUSED_PARAMETER") name: String): T =
|
||||
throw IllegalStateException("Should be replaced by compiler")
|
||||
|
||||
@PublishedApi
|
||||
internal fun safePropertyGet(self: dynamic, getterName: String, propName: String): dynamic {
|
||||
val getter = self[getterName]
|
||||
return if (getter != null) getter.call(self) else self[propName]
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
internal fun safePropertySet(self: dynamic, setterName: String, propName: String, value: dynamic) {
|
||||
val setter = self[setterName]
|
||||
if (setter != null) setter.call(self, value) else self[propName] = value
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements annotated function in JavaScript.
|
||||
|
||||
Reference in New Issue
Block a user