luke_c
10/23/2018, 3:24 PMShawn
10/23/2018, 3:29 PMEgor Trutenko
10/23/2018, 3:35 PMinterface Interface {
fun someFun(p: Int)
}
class Impl: Interface {
override fun someFun(p: Int = 1) {
...
}
}
val i: Interface = Impl()
i.someFun()
You expect that in the last statement someFun
will be invoked with default parameter value (that is, 1
), but i
is of type Interface
and thus its function needs to be supplied with some value, because compiler uses definition from Interface
, not Impl
.luke_c
10/23/2018, 3:39 PMhho
10/23/2018, 3:42 PMluke_c
10/23/2018, 3:44 PM