Commit 784497d
committed
Fix #19607: Allow to instantiate *wildcard* type captures to TypeBounds.
When matching in a match type, if we encounter a `TypeBounds`
scrutinee and we have a wildcard capture on the right, we used to
pick the `hi` bound "because anything between between `lo` and
`hi` would work".
It turns out that *nothing* between `lo` and `hi` works when the
type constructor is invariant. Instead, we must be keep the type
bounds, and instantiate the wildcard capture to a wildcard type
argument.
This is fine because a wildcard capture can never be referred to
in the body of the case. However, previously this could never
happen in successful cases, and we therefore used the presence of
a `TypeBounds` in the `instances` as the canonical signal for
"fail as not specific". We now use a separate `noInstances` list
to be that signal.
This change departs from the letter of the spec but not from its
spirit. As evidenced by the wording, the spec always *intended*
for "the pick" to one that would always succeed. We wrongly
assumed `hi` was always working.1 parent 5c628d9 commit 784497d
File tree
2 files changed
+35
-18
lines changed- compiler/src/dotty/tools/dotc/core
- tests/pos
2 files changed
+35
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3410 | 3410 | | |
3411 | 3411 | | |
3412 | 3412 | | |
| 3413 | + | |
3413 | 3414 | | |
3414 | 3415 | | |
3415 | 3416 | | |
3416 | | - | |
| 3417 | + | |
| 3418 | + | |
| 3419 | + | |
| 3420 | + | |
| 3421 | + | |
| 3422 | + | |
| 3423 | + | |
| 3424 | + | |
| 3425 | + | |
| 3426 | + | |
| 3427 | + | |
| 3428 | + | |
| 3429 | + | |
3417 | 3430 | | |
3418 | 3431 | | |
3419 | | - | |
3420 | | - | |
3421 | | - | |
3422 | | - | |
3423 | | - | |
3424 | | - | |
| 3432 | + | |
| 3433 | + | |
3425 | 3434 | | |
3426 | 3435 | | |
3427 | 3436 | | |
3428 | 3437 | | |
3429 | | - | |
| 3438 | + | |
3430 | 3439 | | |
3431 | | - | |
3432 | | - | |
| 3440 | + | |
| 3441 | + | |
3433 | 3442 | | |
3434 | | - | |
3435 | | - | |
| 3443 | + | |
| 3444 | + | |
3436 | 3445 | | |
3437 | 3446 | | |
3438 | 3447 | | |
| |||
3508 | 3517 | | |
3509 | 3518 | | |
3510 | 3519 | | |
3511 | | - | |
3512 | | - | |
3513 | | - | |
3514 | | - | |
3515 | | - | |
3516 | | - | |
| 3520 | + | |
| 3521 | + | |
3517 | 3522 | | |
3518 | 3523 | | |
3519 | 3524 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments