Skip to content

Commit 6a41a2b

Browse files
authored
Merge pull request #11975 from dotty-staging/i11967
Add regression test for i11967
2 parents 3bc4fed + e71985b commit 6a41a2b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed
+11-7
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)