I had a pair of “matching” interfaces in Kotlin and Java (used from two different Android modules that don’t have access to each other), like so:
Java:
boolean isDebugEnabled();
boolean isInTestMode();
void signOut();
Kotlin:
val isDebugEnabled: Boolean
val isInTestMode: Boolean
fun signOut()
I had a java class that implemented both interfaces using signatures like the Java interface above, and it satisfied the Kotlin interface as expected. This is fine, been living with this for months.
…but then I tried to convert the Java class to Kotlin and the symmetry was broken. I could not satisfy both interfaces no matter what I did. Tried splashing in some annotations to the fields, didn’t matter. I get a message from the linter “Accidental override, the following declarations have the same signature”. Tried splashing in @JvmName
in places, @JvmField
in other places, nothing worked. This modality of Java->Kotlin interface only works if I implement using a Java class.
…or am I missing something?
(Obviously this is easily worked around by changing one or both of the interfaces, but I really like the way it worked before! )