diff --git a/compiler/src/dotty/tools/package.scala b/compiler/src/dotty/tools/package.scala index 79488c70cf6b..57a58151acc7 100644 --- a/compiler/src/dotty/tools/package.scala +++ b/compiler/src/dotty/tools/package.scala @@ -42,4 +42,11 @@ package object tools { def unreachable(x: Any = "<< this case was declared unreachable >>"): Nothing = throw new MatchError(x) + + transparent inline def assertShort(inline assertion: Boolean, inline message: Any = null): Unit = + if !assertion then + val msg = message + val e = if msg == null then AssertionError() else AssertionError("assertion failed: " + msg) + e.setStackTrace(Array()) + throw e }