Skip to content

Commit e71985b

Browse files
committed
Add test for i11967
1 parent 01eb5a2 commit e71985b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
// Test flow-typing when NotNullInfos are from non-null cases
1+
// Test flow-typing when NotNullInfos are from cases
22

33
object MatchTest {
4-
locally {
5-
val s: String|Null = ???
6-
s match {
7-
case _: String => println(s.length)
8-
case _ => println(0)
9-
}
4+
5+
def lengthOfStringOrNull(s: String | Null): Int = s match {
6+
case _: String => s.length
7+
case _ => 0
8+
}
9+
10+
def stringOrNullToString(s: String | Null): String = s match {
11+
case null => "null"
12+
// after the null case, s becomes non-nullable
13+
case _ => s
1014
}
1115
}

0 commit comments

Comments
 (0)