@@ -16,7 +16,7 @@ import scala.language.`2.13`
1616import scala .language .implicitConversions
1717
1818import scala .collection .{mutable , immutable , ArrayOps , StringOps }, immutable .WrappedString
19- import scala .annotation .{elidable , experimental , implicitNotFound }, elidable .ASSERTION
19+ import scala .annotation .{elidable , experimental , implicitNotFound , publicInBinary , targetName }, elidable .ASSERTION
2020import scala .annotation .meta .{ companionClass , companionMethod }
2121import scala .annotation .internal .{ RuntimeChecked }
2222import scala .compiletime .summonFrom
@@ -285,8 +285,8 @@ object Predef extends LowPriorityImplicits {
285285 * @param assertion the expression to test
286286 * @group assertions
287287 */
288- @ elidable(ASSERTION )
289- def assert (assertion : Boolean ): Unit = {
288+ @ elidable(ASSERTION ) @ publicInBinary
289+ @ targetName( " assert " ) private [scala] def scala2Assert (assertion : Boolean ): Unit = {
290290 if (! assertion)
291291 throw new java.lang.AssertionError (" assertion failed" )
292292 }
@@ -300,12 +300,18 @@ object Predef extends LowPriorityImplicits {
300300 * @param message a String to include in the failure message
301301 * @group assertions
302302 */
303- @ elidable(ASSERTION ) @ inline
304- final def assert (assertion : Boolean , message : => Any ): Unit = {
303+ @ elidable(ASSERTION ) @ inline @ publicInBinary
304+ @ targetName( " assert " ) private [scala] final def scala2Assert (assertion : Boolean , message : => Any ): Unit = {
305305 if (! assertion)
306306 throw new java.lang.AssertionError (" assertion failed: " + message)
307307 }
308308
309+ transparent inline def assert (inline assertion : Boolean , inline message : => Any ): Unit =
310+ if ! assertion then scala.runtime.Scala3RunTime .assertFailed(message)
311+
312+ transparent inline def assert (inline assertion : Boolean ): Unit =
313+ if ! assertion then scala.runtime.Scala3RunTime .assertFailed()
314+
309315 /** Tests an expression, throwing an `AssertionError` if false.
310316 * This method differs from assert only in the intent expressed:
311317 * assert contains a predicate which needs to be proven, while
0 commit comments