Skip to content

Commit 02141bf

Browse files
committed
Avoid creating closure for asserts
1 parent 20425bb commit 02141bf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

library/src/dotty/DottyPredef.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,18 @@ object DottyPredef {
2424
* `discardForView` from two to one.
2525
*/
2626
abstract class ImplicitConverter[-T, +U] extends Function1[T, U]
27+
28+
@inline final def assert(assertion: Boolean, message: => Any): Unit = {
29+
if (!assertion)
30+
assertFail(message)
31+
}
32+
33+
@inline final def assert(assertion: Boolean): Unit = {
34+
if (!assertion)
35+
assertFail()
36+
}
37+
38+
final def assertFail(): Unit = throw new java.lang.AssertionError("assertion failed")
39+
final def assertFail(message: => Any): Unit = throw new java.lang.AssertionError("assertion failed: " + message)
40+
2741
}

0 commit comments

Comments
 (0)