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#5067: Ycheck failure in pattern matching against a value of type Nothing
When desugaring pattern matching code for expressions where the
matched value has type `Null` or `Nothing`, we used to generate code
that's type-incorrect.
Example:
```
val Some(x) = null
```
got desugared into
```
val x: Nothing =
matchResult1[Nothing]:
{
case val x1: Null @unchecked = null: Null @unchecked
if x1.ne(null) then
{
case val x: Nothing = x1.value.asInstanceOf[Nothing]
return[matchResult1] x: Nothing
}
else ()
return[matchResult1] throw new MatchError(x1)
}
```
There were two problems here:
1) `x1.ne(null)`
2) `x1.value`
In both cases, we're trying to invoke methods that don't exist for type
`Nothing` (and #2 doesn't exist for `Null`).
This commit changes the desugaring so we generate a no-op for unapply
when the value matched has type `Nothing` or `Null`. This works because
the code we used to generate is never executed (because the `x1.ne(null)`) check.
0 commit comments