Closed
Description
Compiler version
Scala 3.0.0-RC2 with -Yexplicit-nulls
Minimized code
// This works correctly
def f1(s: String | Null): String = if(s == null) "other" else s
// This fails to compile
def f(s: String | Null): String = s match {
case null => "other"
case s => s
}
Output
case s => s
^
Found: (s : String | Null)
Required: String
Expectation
My expectation is that what happens with def f(s: String | Null): String = if(s == null) "other" else s
should apply to pattern matching too.
I couldn't find any open issue treating this, so I opened one.
Thank you.