Skip to content

Commit 75471fb

Browse files
committed
Implement an internal "assertShort" utility
1 parent 2844c2b commit 75471fb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

compiler/src/dotty/tools/package.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,11 @@ package object tools {
4242

4343
def unreachable(x: Any = "<< this case was declared unreachable >>"): Nothing =
4444
throw new MatchError(x)
45+
46+
transparent inline def assertShort(inline assertion: Boolean, inline message: Any = null): Unit =
47+
if !assertion then
48+
val msg = message
49+
val e = if msg == null then AssertionError() else AssertionError("assertion failed: " + msg)
50+
e.setStackTrace(Array())
51+
throw e
4552
}

0 commit comments

Comments
 (0)