Closed smarter closed 3 years ago
Ah, it seems pretty clear that we need to add approx in that case, given the definition of widenSingletons
(not to be confused with widenSingleton
!). I can have a look at other calls to that function in TypeComparer.
It's not just widenSingletons
I think, for example there's recur(tp1.join, tp2)
in joinOK
This compiles, but shouldn't:
I think the problem is that when a union type is on the lhs, we can infer sufficient constraints regardless of whether we're in GadtConstraintInference mode or not, for example: https://github.com/lampepfl/dotty/blob/b5a171536a8ce4294c2107770f47cb97dfc148f5/compiler/src/dotty/tools/dotc/core/TypeComparer.scala#L450 If I rewrite this to:
Then the example above doesn't compile anymore:
But I haven't checked what other consequences this would have or if there are other cases that would need to be changed like this too.
/cc @odersky