Skip to content

Commit 434204f

Browse files
committed
Use a definition of def notNull that does not require NotNull.
1 parent 1726660 commit 434204f

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

tests/pos/notNull.scala

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
11
trait Null extends Any
22
object Test with
3-
def notNull(x: Any): x.type & NotNull =
3+
def notNull[A](x: A | Null): x.type & A =
44
assert(x != null)
55
x.asInstanceOf // TODO: drop the .asInstanceOf when explicit nulls are implemented
66

77
locally {
88
val x: (Int | Null) = ???
99
val y = x; val _: Int | Null = y
1010
}
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-
}
1611
locally {
1712
val x: Int | Null = ???
1813
val y = notNull(identity(x)); val yc: Int = y
1914
val z = notNull(x); val zc: Int = z
2015
}
21-
locally {
22-
val x: Int | Null = ???
23-
val y = identity(x).$nn; val yc: Int = y
24-
val z = x.$nn; val zc: Int = z
25-
}
2616
class C { type T }
2717
locally {
2818
val x: C { type T = Int } = new C { type T = Int }
29-
val y: x.$nn.T = 33
19+
val xnn: x.type & C { type T = Int } = notNull(x)
20+
val y: xnn.T = 33
3021
val z = y; val zc: Int = z
3122
}
32-
33-

0 commit comments

Comments
 (0)