Saharath Kleips
12/12/2023, 11:43 PMwhere
clause produces some weird behavior on what the type of box
ends up being when combined with a star projection (Baz<*>
):
interface Foo {
fun isFoo(): Boolean
}
interface Bar{
fun isBar(): Boolean
}
interface Baz<T> where T : Foo, T : Bar {
val box: T
}
val baz: Baz<*> = TODO()
baz.box.isFoo() // OK where T : Foo, T : Bar -- NOT OK where T : Bar, T : Foo
baz.box.isBar() // NOT OK where T : Foo, T : Bar -- OK where T : Bar, T : Foo
Is this somehow intentional? Is there a workaround?ephemient
12/13/2023, 4:19 AM<*>
you are bypassing generic types - it is a raw type, not an "any type that works"ephemient
12/13/2023, 4:21 AMephemient
12/13/2023, 4:24 AMinterface Baz {
val box: Foo // or whichever one is mentioned first
}
when you remove the type machinery (that magically inserts as T
when you have an actual T
)ephemient
12/13/2023, 4:24 AMSam
12/13/2023, 8:28 AMSaharath Kleips
12/13/2023, 4:40 PMSaharath Kleips
12/13/2023, 4:57 PM