Commit 1b3a52c
authored
Fix widening logic to keep instantiation within bounds (#16417)
Before this commit, if `Config.checkConstraintsSatisfiable` was set to
`true`, then tests/pos/cls.scala would fail on `val b1` with:
Y is constrained to be >: Matchable but attempted to instantiate it to
Int | String
This happens because when `widenInferred` widens a union, it constrains
the upper-bound of the parameter being instantiated to be a subtype of
that union (`tpw <:< bound`). This is usually fine, but if
`isTransparent` is true, we'll return the original unwidened type, which
is now out of bounds.
To avoid this inconsistency, the `isTransparent` check is now moved
before the subtype check that updates the bounds.1 file changed
+5
-8
lines changedLines changed: 5 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | | - | |
628 | | - | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
629 | 630 | | |
630 | 631 | | |
631 | 632 | | |
| |||
647 | 648 | | |
648 | 649 | | |
649 | 650 | | |
650 | | - | |
| 651 | + | |
651 | 652 | | |
652 | 653 | | |
653 | 654 | | |
| |||
663 | 664 | | |
664 | 665 | | |
665 | 666 | | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
| 667 | + | |
671 | 668 | | |
672 | 669 | | |
673 | 670 | | |
| |||
0 commit comments