You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cut the Gordian Knot: Don't widen unions to transparent (#15642)
The idea is that some unions usually make more sense than others. For
instance,
if `Apply` and `Ident` are case classes that extend `Tree`, it makes
sense to
widen `Apply | Ident` to `Tree`. But it makes less sense to widen
`String | Int`
to `Matchable`.
Making sense means: (1) Matches our intuitive understanding, and (2)
choosing not to
widen would usually not cause errors.
To explain (2): In the `Tree` case it might well be that we define a
given for `Inv[Tree]` for
invariant class `Inv`, and then we would not find that given for
`Inv[Apply | Ident]`.
But it's much less likely that we are looking for a given of type
`Inv[Any]`.
This commit does two things:
- add logic not to widen a union if the result is a product of only
transparent traits or classes.
- treat `Any`, `AnyVal`, `Object`, and `Matchable` as transparent.
0 commit comments