Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information