karelpeeters
06/16/2018, 9:09 PM(Any) -> Unit is a subtype of (String) -> Unit, so you're supposed to be able the always replace the latter with the former if something is taking it.ghedeon
06/17/2018, 5:05 AMkarelpeeters
06/17/2018, 8:02 AMAny is a supertype of String, (Any) -> Unit is a subtype of (String) -> Unit.ghedeon
06/17/2018, 8:45 AMkarelpeeters
06/17/2018, 8:56 AM(Any) -> Unit is a subtype of (String) -> Unit, so functions accepting (String) -> Unit should also accept (Any) -> Unit.karelpeeters
06/17/2018, 8:56 AMkarelpeeters
06/17/2018, 9:00 AMinterface A
interface B: A
fun f(a: A) {}
fun g(b: B) {}
val value: B = ...
g(value)karelpeeters
06/17/2018, 9:01 AMg you can always replace that with a call to f, right? Because f simply accepts whatever g does and more.karelpeeters
06/17/2018, 9:02 AMval func: (B) -> Unit = ::f
val value: B = ...
func(value) is perfectly okay.karelpeeters
06/17/2018, 9:03 AM(B) -> Unit by a function (A) -> Unit, which makes (A) -> Unit a subtype of (B) -> Unit.karelpeeters
06/17/2018, 9:03 AMrobstoll
06/17/2018, 9:30 AM