https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
t

timm

01/30/2018, 12:08 PM
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

anton.bannykh

01/30/2018, 12:10 PM
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

timm

01/30/2018, 12:13 PM
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

anton.bannykh

01/30/2018, 1:03 PM
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

timm

01/30/2018, 1:07 PM
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

anton.bannykh

01/30/2018, 1:11 PM
😃 I think @udalov might be able to answer your question.
t

timm

01/30/2018, 1:15 PM
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

anton.bannykh

01/30/2018, 1:16 PM
Sounds reasonable
t

timm

01/30/2018, 1:18 PM
We can Probably write Java-Wrappers as well. And delegate to the kotlin methods 🤔
a

anton.bannykh

01/30/2018, 3:16 PM
Yeah, that would make sense. 😃
u

udalov

01/31/2018, 9:17 PM
Please report an issue. We did not encounter this problem, but it sounds fixable
10 Views