Skip to content

Commit b96d7e3

Browse files
committed
add test with flow-sensitive reasoning about nulls
1 parent 56ac3a6 commit b96d7e3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/explicit-nulls/warn/unnecessary-nn.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ def f5a[T <: String](s: T): String = s.nn // warn
1010

1111
// flexible types
1212
def f7(s: String|Null) = "".concat(s.nn) // warn
13-
def f8(s: String): String = s.trim().nn // OK because the .nn could be useful as a dynamic null check
13+
def f8(s: String): String = s.trim().nn // OK because the .nn could be useful as a dynamic null check
14+
15+
16+
def f9(s: String|Null): String =
17+
if(s == null) "default"
18+
else s.nn // warn

0 commit comments

Comments
 (0)