Widening Union Types have been discussed here but I can't seem to find an answer to the following case
Let's start by looking at the following
val x = List(1, 2, "a")
This heterogeneous list is inferred as List[Any]
Just like it would in Scala 2
However the following
val x2 = List(List(1, 2), Vector("a", "b"))
is inferred as List[scala.collection.immutable.AbstractSeq[Int | String]]
This is rather confusing behavior. Why does two disjoint types' LUB get inferred as Any
in one case but a union type in another?
If it is just a design decision, are there any such cases that one should be aware of ?