Apparently I need to ask something the third time today:
Is there any useful application to kinda “redeclaring” a method in an interface extending another interface or is it just a “cosmetic” thing?
E.g.
in your example though, there's no possibility of that so it's nearly the same whether you declare
override fun a()
or not
ephemient
11/28/2020, 12:17 AM
aside from bytecode and reflection, it shouldn't be an observable difference
c
Chilli
11/28/2020, 12:28 AM
Just as I thought, thanks!
j
jbnizet
11/28/2020, 8:25 AM
And let’s not forget: documentation. By redeclaring the function, you can document it to provide a more specific documentation, clarifying what that function is supposed to do on implementations of B.
t
tseisel
11/28/2020, 11:19 AM
I just found that when redefining
fun a
in
interface B
, you also have the opportunity to act on the default behavior of the function:
• If
A
defines a default implementation of
fun a
and
B
redefines
fun a
without a body, then implementations of
B
must define
fun a
.
• If
A
and
B
both have a default impl of
fun a
, then its the default impl of
B
that's used. You have the opportunity to call the default of