Commit 19dbbf5
authored
Intuitively, `glb(S1^C1, S2^C2)` should capture `C1 ⊓ C2`, where `⊓`
denotes the glb of capture sets. When computing `glb(tp1, tp2)`, if
`tp1` matches `CapturingType(parent1, refs1)`, it captures `C0 ++ refs1`
where `C0` is the nested capture sets inside `parent1`. Denote the
capture set of `tp2` with `C2`, the result should capture `(C0 ++ refs1)
⊓ C2`. Presumably, `⊓` distributes over the union (`++`); therefore `(C0
++ refs1) ⊓ C2` equals `C0 ⊓ C2 ++ refs1 ⊓ C2`.
Previously, if `C2` is a subcapture of `refs1`, it is simply dropped.
However, based on the above reasoning, we have `refs1 ⊓ C2` equals `C2`;
therefore `C0 ⊓ C2 ++ refs1 ⊓ C2` equals `C0 ⊓ C2 ++ C2`. `C2` should
not be dropped, but rather kept. This PR fixes the logic to behave
correctly.
Fixes #18246.
File tree
4 files changed
+20
-6
lines changed- compiler/src/dotty/tools/dotc/core
- tests/neg-custom-args/captures
4 files changed
+20
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2618 | 2618 | | |
2619 | 2619 | | |
2620 | 2620 | | |
2621 | | - | |
| 2621 | + | |
| 2622 | + | |
2622 | 2623 | | |
2623 | | - | |
2624 | | - | |
2625 | | - | |
2626 | | - | |
| 2624 | + | |
| 2625 | + | |
2627 | 2626 | | |
2628 | 2627 | | |
2629 | 2628 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1940 | 1940 | | |
1941 | 1941 | | |
1942 | 1942 | | |
1943 | | - | |
| 1943 | + | |
1944 | 1944 | | |
1945 | 1945 | | |
1946 | 1946 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments