We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 3bc4fed + e71985b commit 6a41a2bCopy full SHA for 6a41a2b
tests/explicit-nulls/pos/flow-match.scala
@@ -1,11 +1,15 @@
1
-// Test flow-typing when NotNullInfos are from non-null cases
+// Test flow-typing when NotNullInfos are from cases
2
3
object MatchTest {
4
- locally {
5
- val s: String|Null = ???
6
- s match {
7
- case _: String => println(s.length)
8
- case _ => println(0)
9
- }
+
+ def lengthOfStringOrNull(s: String | Null): Int = s match {
+ case _: String => s.length
+ case _ => 0
+ }
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
14
}
15
0 commit comments