Commit 8de6d88
authored
Sharpen range approximation for applied types with capture set ranges (#16261)
This is a stopgap to avoid approximating the core type to Nothing. It
can probably be dropped once we have capture set ranges that we can keep
as inference results. The problem is, what should be the approximation
of the range
C[{cs1} A .. {cs2} A]
where the type constructor `C` is non-variant? If the variance of the
enclosing map is positive, this is `C[? >: {cs1} A <: {cs2} A]`, which
is a supertype of both range end points `C[{cs1} A]` and `C[{cs2} A]`.
But if the variance is negative, we would normally fall back to
`Nothing`, since that is the only known subtype of both range end
points. This reasoning seems too strict for capture checking. In a
sense, we have already inferred `C[A]` before; now we just need to find
out what the set should be. What we are after is a notion of a _capture
set range_. I.e. something like
C[{cs1}..{cs2} A]
with the meaning that the capture set of `C` is an unknown set between
`cs1` and `cs2`. We don't have that abstraction yet, so for now we
approximate by the bounds, which avoids the failures, even though its
soundness status is currently a bit unclear.File tree
5 files changed
+45
-3
lines changed- compiler/src/dotty/tools/dotc/core
- tests
- neg-custom-args/captures
- pos-custom-args/captures
5 files changed
+45
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
536 | 548 | | |
537 | 549 | | |
538 | 550 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6027 | 6027 | | |
6028 | 6028 | | |
6029 | 6029 | | |
| 6030 | + | |
| 6031 | + | |
| 6032 | + | |
6030 | 6033 | | |
6031 | | - | |
| 6034 | + | |
6032 | 6035 | | |
6033 | 6036 | | |
6034 | 6037 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments