Commit fc593df
authored
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.
---
Companion PR to fix the spec/SIP:
scala/improvement-proposals#77
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 | |
|---|---|---|---|
| |||
3388 | 3388 | | |
3389 | 3389 | | |
3390 | 3390 | | |
| 3391 | + | |
3391 | 3392 | | |
3392 | 3393 | | |
3393 | 3394 | | |
3394 | | - | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
3395 | 3408 | | |
3396 | 3409 | | |
3397 | | - | |
3398 | | - | |
3399 | | - | |
3400 | | - | |
3401 | | - | |
3402 | | - | |
| 3410 | + | |
| 3411 | + | |
3403 | 3412 | | |
3404 | 3413 | | |
3405 | 3414 | | |
3406 | 3415 | | |
3407 | | - | |
| 3416 | + | |
3408 | 3417 | | |
3409 | | - | |
3410 | | - | |
| 3418 | + | |
| 3419 | + | |
3411 | 3420 | | |
3412 | | - | |
3413 | | - | |
| 3421 | + | |
| 3422 | + | |
3414 | 3423 | | |
3415 | 3424 | | |
3416 | 3425 | | |
| |||
3486 | 3495 | | |
3487 | 3496 | | |
3488 | 3497 | | |
3489 | | - | |
3490 | | - | |
3491 | | - | |
3492 | | - | |
3493 | | - | |
3494 | | - | |
| 3498 | + | |
| 3499 | + | |
3495 | 3500 | | |
3496 | 3501 | | |
3497 | 3502 | | |
| |||
| 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