I'm working on adding multiplatform support to a p...
# compiler
j
I'm working on adding multiplatform support to a plugin that previously only supported the JVM. It replaces the fake overrides for
equals
,
hashCode
, and
toString
with real implementations. This works on JVM and as-is on the newly-added JS target. On native targets, however, only
hashCode
and
toString
work. Replacing the body of the fake
equals
function and marking it as non-fake somehow isn't enough. Debugging at runtime, I always end up in
kotlin_Any_equals
. Dumping the LLVM IR after the
VerifyBitcode
phase shows that the
equals
function is completely absent. Dumping the IR after the plugin matches on the
equals
method shows that it successfully replaced the function body with the new IR, but somewhere it's getting removed still. Any ideas?
I guess I can just dump after all phases and grep for when it disappears, assuming it makes it in after the compiler plugin phase.
p
In native Any.equals has external flag. Maybe you accidentially copied it somewhere? And corresponding annotation, which sais, that the call is in fact call of this native function.
👏 1
j
Yeeeeep setting
external = false
fixes it. gratitude thank yougratitude thank yougratitude thank yougratitude thank yougratitude thank you I think long term the better approach is replacing the whole function rather than trying to update it, but I'm migrating the project slowly and that's a big change.
d
What does "external" mean in this context?
p
It means, that there is no kotlin implementation of this function, but instead of this compiler know how to compile it in something custom.
d
Ah, so the generated IR code is "external" to the original source. Cool, thanks!
p
I'd say generated llvm IR, not kotlin IR. External generally means "function is implemented not in source code, but somewhere else".
👍 1