While in JVM it works, in JS it cause name collisi...
# javascript
p
While in JVM it works, in JS it cause name collision:
Copy code
class A {
  val test: Any by lazy {...}
  fun test(): Any {...}
}
j
p
Want to avoid such things.
j
you have no choice, because a method in JS is simply a property with a function as a value
which means you try to create two properties named
test
p
That i understand. Wonder why than it allowed in Kotlin MPP. Better to rename function or propery in common code then.
a
No way that is better. Introducing constraints of other platforms to common code is a poor approach in my opinion. Let kotlin be kotlin (as best as possible), if there are platform specific constraint, make it a language feature (e.g. using @JsName, or @JvmOverloads) to cater for the specific platform. But by no means, cripple the beauty of kotlin
👍 1
💯 3
p
Looks messy for my own opinion. It is not library specialization, it is the language future that pretend to be MPP.
p
I get your point @PHondogo and I sometimes have this aftertaste as well. I’d like to just use Kotlin without polluting the common code with platform-specific annotations.
What I’d expect in this very case (name clash) is using name mangling. If a given symbol needs to have a predictable name, then use
@JsName
p
Yes. Language rules and common code must be common. And in case of need of exact name one should use annotation. Now it is upside down.
👍 1