Skip to content

Commit 1b3ca7b

Browse files
committed
Test case
This test implements a notNull operation and demonstrates that it works as required.
1 parent da4bed3 commit 1b3ca7b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/pos/notNull.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
trait Null extends Any
2+
object Test with
3+
def notNull(x: Any): x.type & NotNull =
4+
assert(x != null)
5+
x.asInstanceOf // TODO: drop the .asInstanceOf when explicit nulls are implemented
6+
7+
locally {
8+
val x: (Int | Null) = ???
9+
val y = x; val _: Int | Null = y
10+
}
11+
locally {
12+
val x: (Int | Null) & NotNull = ???
13+
val y = identity(x); val yc: Int = y
14+
val z = x; val zc: Int = z
15+
}
16+
locally {
17+
val x: Int | Null = ???
18+
val y = notNull(identity(x)); val yc: Int = y
19+
val z = notNull(x); val zc: Int = z
20+
}
21+

0 commit comments

Comments
 (0)