Data class - implement Java interface with some getters


maybe I’m doing something wrong or this is intended limitation of Kotlin, but let’s say we have interface in Java:
public interface SomeInterface {
int getX();

and I would like to implement it as data class. But this:

data class X (override val x : Int) : SomeInterface

<- gives error (“x overrides nothing”).

If I remove “override” word, I will get error:

Accidental override: The following declarations have the same JVM signature (getX()I):
public final fun (): Int defined in mypackage.X
public abstract fun getX(): Int defined in mypackage.X

and the whole class is marked as not implementing interface properly


This is currently not supported. See in YouTrack.