Hi, I think this should be considered platform dec...
# compiler
e
Hi, I think this should be considered platform declaration clash but it is not(compiler generated getter and user defined getX function with same arguments list but different return type with nullable reference type and its corresponding primitive type). This can be a problem when you use this style of declarations with java reflection(like Hibernate) because this can result in platform dependent behaviour.
Copy code
class A(val x:Long?=null) {
    fun getX():Long {
        println("getX() called: $x");
        return x ?: -1
    }
}
This compiles well and result in a class file with A class with two conflicting overloaded functions: public final java.lang.Long getX(); // from x nullable property descriptor: ()Ljava/lang/Long; public final long getX(); // from not nullable Long (compiled into java long) descriptor: ()J
u
This is not a platform declaration clash because these declarations are technically not clashing from the Kotlin's point of view. There's a request at KT-23913 to improve behavior in such cases though. Personally I believe it could be a warning or an error in this special "Java API" mode.
e
I understand. I was too java centric 🙂
Thank you.