You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix#19607: Allow to instantiate *wildcard* type captures to TypeBounds. (#19627)
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
0 commit comments