Skip to content

Commit b73589a

Browse files
committed
Test case
This test implements a notNull operation and demonstrates that it works as required. Also: Fix repltest
1 parent da4bed3 commit b73589a

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

compiler/test-resources/repl/i5218

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ val tuple: (Int, String, Long) = (1,2,3)
33
scala> 0.0 *: tuple
44
val res0: (Double, Int, String, Long) = (0.0,1,2,3)
55
scala> tuple ++ tuple
6-
val res1: Int *: String *: Long *: scala.Tuple.Concat[Unit, tuple.type] = (1,2,3,1,2,3)
6+
val res1: Int *: String *: Long *: tuple.type = (1,2,3,1,2,3)

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)