From 75471fb4876f1e74c3ae8b3727cdff5eb94b9eea Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 11 Oct 2022 08:37:36 +0100 Subject: [PATCH] Implement an internal "assertShort" utility --- compiler/src/dotty/tools/package.scala | 7 +++++++ 1 file changed, 7 insertions(+) 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 }