Hullaballoonatic
11/21/2019, 7:28 PMF
and Foo<F>
here:
interface Foo<F: Foo<F>> {
val a: F
val b: Foo<F>
}
so what is assignable to a and b?Ruckus
11/21/2019, 7:30 PMHullaballoonatic
11/21/2019, 7:46 PMRuckus
11/21/2019, 7:54 PMa
can only take the F
specified by the implementation, whereas b
can take any Foo<f>
.
For example:
interface Bar : Foo<Bar>
class Quux : Foo<Bar> {
override val a: Bar = ... // Must be a `Bar`
override val b: Foo<Bar> = ... // Can be `this` or `a` or any other `Foo<Bar>`
}
Hullaballoonatic
11/21/2019, 8:42 PM