sorry if my question was already asked but I could not find any answer.
I would like to have an extension function to extract the first element of a collection and coerce it to a specific subtype.
At first I had the function “oldFirstAs” but it is not good because I can pass anything as T. And I am forced to used this dirty @Suppress
Because I want compile time type safety I came with the second function “firstAs”
As you can see, the type T has an Upper Bound to X, the type of the collection. Why is the compiler letting me call with X=A and T=C, without raising an error ?