Closed
Description
[EDIT] After discussion on gitter, I managed to simplify the example, and more convinced that careful planning should be taken before considering changing this behavior.
As discussed on the PR introducing literal type operations, there is a problem when attempting to use covariant literal types.
Adding a <: Singleton
upper bound resolved this issue, but IMO it feels hacky.
minimized code
class Foo[+LW] {
def + [RW](that : Foo[RW]) = that
}
val f1 = new Foo[1]
val f2 = new Foo[2]
val f3 = f1 + f2
val f3a : Foo[2] = f1 + f2 //works
val f3b : Foo[2] = f3 //Error: type mismatch;
Compilation output
Found: (f3 : Foo[Int])
Required: Foo[(2 : Int)]
expectation
No error