“A union type is widened in type inference to the least supertype that is not a union type.”
trait Kind case object Var extends Kind case object Val extends Kind case object Const extends Kind val x = Set(if condition then Val else Var)
Here is the inferred type of x will be Set[Kind]
The more I use union types the more I feel the lack of inference for them.
Is there a reason why the inferred type of x is not
Val.type | Var.type ?