Daniele Segato
09/04/2018, 9:37 AMView
is part of the Android framework and has methods like:
public int getPaddingLeft() { ... }
my Java interface was:
interface MyInterface {
int getPaddingLeft();
}
And for my widget in java I just had to implement the interface without doing anything else, the methods were already there.
With Kotlin tough, the interface become a val
declaration and the compiler complains I should implement those `val`s. If I do I get the error:
Accidental override: The following declarations have the same JVM signature (getPaddingRight()I):
* public open fun <get-paddingRight>(): Int defined in my.package.MyWidget
* public open fun getPaddingRight(): Int defined in my.package.MyWidget"
the error happens on the get()
The second one is of course the Platform method.
Is there a way to tell Kotlin those are the same thing and I do not need to override anything?
see kotlin codegildor
09/04/2018, 9:40 AMval paddingRight: Int
becomes
fun getPaddingRight(): Int
Daniele Segato
09/04/2018, 9:42 AMpaddingRight
as if it was a val/var. From whoever use my Interface instead i am then forced to use the getPaddingRight()
method instead.
Isn't there a way to instruct Kotlin that those methods are actually the val?gildor
09/04/2018, 9:43 AMDaniele Segato
09/04/2018, 9:51 AMgildor
09/04/2018, 9:51 AMDaniele Segato
09/04/2018, 9:57 AMkarelpeeters
09/04/2018, 10:07 AMgildor
09/04/2018, 10:12 AMsome mitigations strategies like the one you propose are possible. We’ll probably look into them at some point. I’m not prepared to describe all the possible risks, but I’m sure there are quite a few things to be checked before we can say it doesn’t break anything.
karelpeeters
09/04/2018, 10:14 AM