Hey guys. When i am using the annotion `@JvmName`i...
# multiplatform
t
Hey guys. When i am using the annotion `@JvmName`in my common code, the compiler fails to compile the JS Module using the common code. (JvmName is internal to kotlin.jvm). Is there a fix for it?
a
You could create an expect annotation in common module and typealias it to JvmName in the JVM module: https://discuss.kotlinlang.org/t/how-to-add-jsname-to-a-platform-function/6238/3
t
I did this for JsName already. But it doesn't seem to work for the jvm version of it. Especially not when used with
@file:...
a
Yep, it look like the typealising hack doesn't work for
@file
. For the method names it actually does work, but IDEA fails to recognize that (marks the code red).
cc @udalov
t
Are there any plans to find a solution for this? Current workaround seems to be to write expect & actual classes containing the same code for jvm and js modules 😕
Thanks for checking though 😉
a
😃 I think @udalov might be able to answer your question.
t
Okay 😉 Just to let you know our use case: We have to port parts of an existing java framework to JS. We want to make a PoC in porting it to Kotlin and then compiling it to both JS & Java. We have to stay binary-compatible with the current java version though (thats why we need JvmName, JvmStatic etc.)
a
Sounds reasonable
t
We can Probably write Java-Wrappers as well. And delegate to the kotlin methods 🤔
a
Yeah, that would make sense. 😃
u
Please report an issue. We did not encounter this problem, but it sounds fixable