dave08
12/13/2021, 2:47 PMinterface Foo
class Foo1 : Foo
interface Bar {
fun <T : Foo> baz(foo: T)
}
// This doesn't work, why? It IS derived from Foo... is there any way to do such a thing w/o taking in a Foo and casting it to Foo1?
class Bar2 {
override fun baz(foo: Foo1) = TODO()
}
dave08
12/13/2021, 2:54 PMephemient
12/13/2021, 3:00 PMval bar: Bar
bar.baz(FooNotFoo1()) // legal according to signature, but not according to the Bar2 you wanted to write
dave08
12/13/2021, 3:15 PMT: Foo
there on the function...?Adam Powell
12/13/2021, 3:46 PMT : Foo
is not a Foo1
dave08
12/13/2021, 3:47 PMdave08
12/13/2021, 3:47 PMAdam Powell
12/13/2021, 3:47 PMT : Foo
is still not a Foo1
dave08
12/13/2021, 3:49 PMT : Foo
indicates "a class derived from `Foo`"...?Jacob
12/13/2021, 3:49 PMJacob
12/13/2021, 3:49 PMJacob
12/13/2021, 3:49 PMdave08
12/13/2021, 3:49 PMdave08
12/13/2021, 3:51 PMoverride
to limit a return type to not be nullable for example...?dave08
12/13/2021, 3:51 PMephemient
12/13/2021, 3:51 PMdave08
12/13/2021, 3:52 PMephemient
12/13/2021, 3:52 PMephemient
12/13/2021, 3:52 PMAdam Powell
12/13/2021, 3:53 PMyou can useto limit a return type to not be nullable for example...?override
dave08
12/13/2021, 3:53 PMAdam Powell
12/13/2021, 3:54 PMdave08
12/13/2021, 3:56 PM