Tristan
07/09/2021, 6:58 PMmethod can't be invoked on a non-injected object
Looking on Google, I found this: https://bugs.chromium.org/p/chromium/issues/detail?id=514628
So I looked into the code generated, and indeed, we are not doing what they recommend. The code generated gives:
var tmp0_safe_receiver = Native.adOver;
return tmp0_safe_receiver == null ? null : tmp0_safe_receiver();
For
external object Native {
val adOver: (() -> Unit)?
}
Native.adOver?.invoke()
According to the report, we should generate:
var tmp0_safe_receiver = Native.adOver.bind(Native);
Has it been reported yet? Is there a workaround (other than just use js("Native.adOver?.()")
)ephemient
07/09/2021, 7:01 PMdiesieben07
07/09/2021, 7:08 PMinvoke
call is fiction, in reality you are invoking adOver
as a function, if it is present.
The correct code to preserve the correct receiver would be
var temp = Native.adOver;
return temp == null ? null : temp.call(Native)
Or Kotlin could just target modern Javascript (please...):
Native.adOver?.()
ephemient
07/09/2021, 7:19 PMexternal object Native { fun adOver() }; Native.adOver()
should generate the right codeTristan
07/09/2021, 7:26 PMdiesieben07
07/09/2021, 7:34 PMephemient
07/09/2021, 7:43 PMNative.adOver?.invoke()
Native.adOver?.let { it.invoke() }
different behavior in Kotlin, though, even if it is an external objectephemient
07/09/2021, 7:44 PMexternal object Native {
val adOver: (Native.() -> Unit)?
}
but that's not (currently) legaldiesieben07
07/09/2021, 7:53 PM