https://kotlinlang.org logo
#getting-started
Title
# getting-started
g

gjesse

08/25/2020, 2:08 PM
this seems weird to me - i have a kotlin class that implements an interface by a delegate (using the
by
keyword). the interface is defined in java and has some 
default
 methods. my class does not override those methods. i was expecting them to be forwarded to the delegate, but instead the default version is used. do i have to explicitly override all
default
methods in order to forward them to the delegate?
d

diesieben07

08/25/2020, 2:11 PM
I think this was fixed in 1.4 wiht the new IR (https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-m3-generating-default-methods-in-interfaces/, see "Fixing an issue with delegates" section)
👀 1
g

gjesse

08/25/2020, 2:42 PM
that doesn’t quite seem to be it - i tried recompiling with
-Xjvm-default=all
and it’d didn’t make a difference. also this is a java interface, so i’m not sure it’s the same issue
d

diesieben07

08/25/2020, 2:42 PM
Hm, maybe they did not add it for Java interfaces, which seems like a bug to me.
Are you using the new IR?
Or is that the default already? 🤔
g

gjesse

08/25/2020, 2:44 PM
IR?
g

gjesse

08/25/2020, 2:45 PM
thanks.. i’ve been out of kotlin for a bit 🙂
d

diesieben07

08/25/2020, 2:45 PM
I think the new default handling is a feature of the new IR
g

gjesse

08/25/2020, 2:45 PM
i am not
d

diesieben07

08/25/2020, 2:46 PM
That would probably explain why it has no effect
g

gjesse

08/25/2020, 3:53 PM
eh.. either i can’t figure out the right incantation with maven or it’s not the issue. oh well thanks for your help
3 Views