Commit ab1c90a
committed
Simplify merging in lub/glb, avoid unnecessary constraints
In `mergeIfSuper`, to simplify `tp1 | tp2`, we first check if `tp2` can
be made a subtype of `tp1`. If so we could just return `tp1` but this
isn't what we did before this commit: at that point we checked if `tp1`
could be made a subtype of `tp2` and in that case prefered returning
`tp2` to `tp1`. I haven't been able to find a reason for this (the
comment says "keep existing type if possible" which I don't understand).
On the other hand, I've found cases where this logic broke type
inference because the second subtype check inferred extraneous
constraints (see added testcase). So this commit simply removes this
logic, it does the same for `mergeIfSub` which contains similar logic to
simplify `tp1 & tp2`, though this one is less problematic since it
always runs with frozen constraints.1 parent 266a1e4 commit ab1c90a
File tree
3 files changed
+14
-6
lines changed- compiler/src/dotty/tools/dotc/core
- tests
- neg
- pos
3 files changed
+14
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1983 | 1983 | | |
1984 | 1984 | | |
1985 | 1985 | | |
1986 | | - | |
1987 | | - | |
| 1986 | + | |
1988 | 1987 | | |
1989 | 1988 | | |
1990 | 1989 | | |
| |||
2004 | 2003 | | |
2005 | 2004 | | |
2006 | 2005 | | |
2007 | | - | |
2008 | | - | |
| 2006 | + | |
2009 | 2007 | | |
2010 | 2008 | | |
2011 | 2009 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments