-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Compiler version
3.7
Minimized code
//> using options -Yexplicit-nulls
def main() =
var cache: String | Null = null
try {
cache = ""
} catch {
case e =>
throw e
}
cache.trim()Output
-- [E008] Not Found Error: local/flow.scala:10:8 -------------------------------
10 | cache.trim()
| ^^^^^^^^^^
| value trim is not a member of String | Null.
| Since explicit-nulls is enabled, the selection is rejected because
| String | Null could be null at runtime.
| If you want to select trim without checking for a null value,
| insert a .nn before .trim or import scala.language.unsafeNulls.Expectation
If the try block sets a variable to non-null, and the catch block does not retract it, we can expect the variable outside of the try-catch to be non-null as well