christophsturm
05/22/2024, 7:55 AMdmitriy.novozhilov
05/22/2024, 7:58 AMfun
implicitly, then your users may start to use SAM conversion for it, and in future you can't just add another method to it without breaking users. And this situation can be very frustrating, because you originally had no intent to make it fun
christophsturm
05/22/2024, 8:02 AMJoffrey
05/22/2024, 8:56 AMJoffrey
05/22/2024, 8:58 AMchristophsturm
05/22/2024, 9:00 AMJoffrey
05/22/2024, 9:03 AMchristophsturm
05/22/2024, 9:05 AMdmitriy.novozhilov
05/22/2024, 9:24 AMIsn't adding a function (without default) to an interface a breaking change for inheritors anyway?Yes, indeed 🤦
dmitriy.novozhilov
05/22/2024, 9:31 AMfun
keyword adds an ability to opt-in/opt-out from the conversion behavior, so you can decide do you want for your interface being used this way or not
2. Language compatibility. Introducing the conversion for all interfaces might break a lot of existing code (back then and now also)
fun foo(f: () -> Unit) {} // (1)
class Outer {
fun interface Sam {
fun bar()
}
fun foo(f: Sam) {} // (2)
fun test() {
// if `Sam` is `fun interface` resolved to (2)
// otherwise resolved to (1)
foo { }
}
}
ephemient
05/22/2024, 3:38 PM-Xjvm-default
mode