Skip to content

Commit e66ab23

Browse files
Merge pull request scala#77 from sjrd/match-types-fix-wildcard-capture-logic
Match types: fix wildcard captures handling to match intent.
2 parents 8a15186 + 208a424 commit e66ab23

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

content/match-types-spec.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,9 @@ At the top level, `variance = 1` and `scrutIsWidenedAbstract = false`.
253253
* If `P` is a `TypeWithoutCapture`:
254254
* Do nothing (always succeed).
255255
* If `P` is a `WildcardCapture` `ti = _`:
256-
* If `X` is of the form `_ >: L <: H`, instantiate `ti := H` (anything between `L` and `H` would work here),
257-
* Otherwise, instantiate `ti := X`.
256+
* Instantiate `ti` so that the subtype test in Step (2) above always succeeds:
257+
* If `X` is of the form `_ >: L <: H`, instantiate `ti := H` (resp. `L`, `X`) if `variance = 1` (resp. `-1`, `0`).
258+
* Otherwise, instantiate `ti := X`.
258259
* If `P` is a `TypeCapture` `ti`:
259260
* If `X` is of the form `_ >: L <: H`,
260261
* If `scrutIsWidenedAbstract` is `true`, fail as not specific.

0 commit comments

Comments
 (0)