dotty
dotty copied to clipboard
Stripping away nullability via pattern matching
The following should typecheck, but currently doesn't:
class Foo {
val x: String|Null = "hello"
val res: String = x match {
case null => "it's null"
case s => s
}
}
The current workaround is to annotate s:
class Foo {
val x: String|Null = "hello"
val res: String = x match {
case null => "it's null"
case s: String => s
}
}