Skip to content

Commit 691996a

Browse files
committed
Tweak assert so that nullability info is propagated correctly
1 parent a691e96 commit 691996a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

library/src/dotty/DottyPredef.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ object DottyPredef {
88
assertFail(message)
99
}
1010

11-
inline final def assert(assertion: => Boolean): Unit = {
11+
inline final def assert(assertion: => Boolean) <: Unit = {
1212
if (!assertion)
1313
assertFail()
1414
}
1515

16-
def assertFail(): Unit = throw new java.lang.AssertionError("assertion failed")
17-
def assertFail(message: => Any): Unit = throw new java.lang.AssertionError("assertion failed: " + message)
16+
def assertFail(): Nothing = throw new java.lang.AssertionError("assertion failed")
17+
def assertFail(message: => Any): Nothing = throw new java.lang.AssertionError("assertion failed: " + message)
1818

1919
inline final def implicitly[T](implicit ev: T): T = ev
2020

tests/pos/nullable.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ def test: Unit =
3939
if !(x3 != null) then throw AssertionError()
4040
if x3 == null then impossible(new T{})
4141

42-
//assert(x4 != null)
43-
//if x4 == null then impossible(new T{})
42+
assert(x4 != null)
43+
if x4 == null then impossible(new T{})

0 commit comments

Comments
 (0)