b_camphart
b_camphart

Reputation: 76

JvmName for overloaded Kotlin property

I have an open Kotlin class with the property of value: String.

open class PropHolder {
  open val value: String = ""
}

There is a Java interface with a function String getValue().

public interface Property {
  public String getValue();
}

I have a subclass that inherits from the open Kotlin class and implements the Java interface.

class Child : PropHolder(), Property {
  override fun getValue() = value
}

Running into a Platform declaration clash between:

I've tried:

class Child : PropHolder(), Property {
  override val value: String = ""
    @JvmName("getHeldValue") get() = field

  override fun getValue() = value
}

and:

class Child : PropHolder(), Property {
  @JvmName("getPropValue")
  override fun getValue() = value
}

But, because these are inherited methods, I can't actually override the JvmName for either.

Is there any way to make this work?

Upvotes: 2

Views: 441

Answers (1)

b_camphart
b_camphart

Reputation: 76

It looks like I may have run into this unresolved issue : https://youtrack.jetbrains.com/issue/KT-6653

Current consensus is that there may be a KEEP written soon to explore potential options, but, no nice solution for now.

Upvotes: 1

Related Questions