Not sure where to ask this, but I think this is th...
# compiler
c
Not sure where to ask this, but I think this is the best place. Basically, I'm using
@JvmName
annotations on a lot of my properties in interfaces. Now, this isn't an issue for the most part, except for the very frustrating and ridiculous inapplicable JVM name error that has to be suppressed in every class, but that's not the point of this. When I implement this interface, I would expect that those
@JvmName
named functions would be overridden in the Java code, however this is not the case. What I actually find is that the compiler will generate the property as normal, and then generate normal getters and setters, and make the overridden function a synthetic bridge method that delegates to the getter. Now, here's an example:
Copy code
interface Vehicle {

    @get:JvmName("wheels")
    val wheels: Int
}
Copy code
data class Car(override val wheels: Int) : Vehicle
And the generated code for this ends up looking something like this:
Copy code
public interface Vehicle {

    @JvmName(
        name = "wheels"
    )
    int wheels();
}
Copy code
public final class Car {

    private final int wheels;

    public Car(int wheels) {
        this.wheels = wheels;
    }

    public int getWheels() {
        return wheels;
    }

    // $FF: synthetic method
    // $FF: bridge method
    public int wheels() {
        return getWheels();
    }
}
I am unsure if this is intended behaviour or not, but to me it seems counter-intuitive.
e
https://youtrack.jetbrains.com/issue/KT-20068
@JvmName
on elements to be overridden is simply not well supported