Commit f1674c5
committed
Tune usage of
`resultConforms` should only make us change our mind when we're sure that the
chosen alternative does not fit the result type but another alternative would.
The problem is that due to approximations and adaptation, we can guess wrong on
both counts.
In i22713 in particular, we guessed that the chosen alternative does not
work (but it does because of Unit insertion) and that another alternative would,
but it doesn't because `resultConforms` prefers false positives to false
negatives (the result type is under-approximated to `Nothing` which is
indeed a subtype of `Unit`).
We only really need to prefer false positives to false negatives when
considering whether to discard the currently chosen alternative (because there's
probably a good reason we chose it in the first place), so this commit
introduces a parameter to `resultConforms` to control this.
Fixes #22713.resultConforms to prefer the chosen alternative1 parent 332fceb commit f1674c5
File tree
2 files changed
+20
-6
lines changed- compiler/src/dotty/tools/dotc/typer
- tests/pos
2 files changed
+20
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2125 | 2125 | | |
2126 | 2126 | | |
2127 | 2127 | | |
2128 | | - | |
| 2128 | + | |
2129 | 2129 | | |
2130 | 2130 | | |
2131 | 2131 | | |
2132 | | - | |
| 2132 | + | |
2133 | 2133 | | |
2134 | 2134 | | |
2135 | 2135 | | |
2136 | 2136 | | |
2137 | | - | |
| 2137 | + | |
2138 | 2138 | | |
2139 | 2139 | | |
2140 | | - | |
| 2140 | + | |
2141 | 2141 | | |
2142 | 2142 | | |
2143 | 2143 | | |
| |||
2157 | 2157 | | |
2158 | 2158 | | |
2159 | 2159 | | |
2160 | | - | |
| 2160 | + | |
2161 | 2161 | | |
2162 | | - | |
| 2162 | + | |
2163 | 2163 | | |
2164 | 2164 | | |
2165 | 2165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments