diff --git a/library/src/dotty/DottyPredef.scala b/library/src/dotty/DottyPredef.scala index 75bc60988b42..09facf4b31f8 100644 --- a/library/src/dotty/DottyPredef.scala +++ b/library/src/dotty/DottyPredef.scala @@ -24,4 +24,18 @@ object DottyPredef { * `discardForView` from two to one. */ abstract class ImplicitConverter[-T, +U] extends Function1[T, U] + + @inline final def assert(assertion: Boolean, message: => Any): Unit = { + if (!assertion) + assertFail(message) + } + + @inline final def assert(assertion: Boolean): Unit = { + if (!assertion) + assertFail() + } + + final def assertFail(): Unit = throw new java.lang.AssertionError("assertion failed") + final def assertFail(message: => Any): Unit = throw new java.lang.AssertionError("assertion failed: " + message) + } diff --git a/tests/neg/nopredef.scala b/tests/neg/nopredef.scala index 0079be41ee10..6acf84600978 100644 --- a/tests/neg/nopredef.scala +++ b/tests/neg/nopredef.scala @@ -1,4 +1,5 @@ import Predef.{assert => _} +import dotty.DottyPredef.{assert => _} object Test { assert("asdf" == "asdf") // error: not found assert