Skip to content

Commit 0e50082

Browse files
committed
Add additional flow typing tests
One tests interaction with singleton types; the other with implicits. Fengyun and Alexander suggested these.
1 parent 66e83b4 commit 0e50082

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
// Test that flow typing works well with implicit resolution.
3+
class Test {
4+
implicit val x: String | Null = ???
5+
implicitly[x.type <:< String] // error: x.type is widened String|Null
6+
7+
if (x != null) {
8+
implicitly[x.type <:< String] // ok: x.type is widened to String
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Test that flow typing works well with singleton types.
2+
3+
class Test {
4+
val x : String | Null = ???
5+
if (x != null) {
6+
val y: x.type = x
7+
y.toLowerCase // ok: y should have type `String` in this branch
8+
}
9+
}

0 commit comments

Comments
 (0)