@@ -16,7 +16,7 @@ import scala.language.`2.13`
16
16
import scala .language .implicitConversions
17
17
18
18
import 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
20
20
import scala .annotation .meta .{ companionClass , companionMethod }
21
21
import scala .annotation .internal .{ RuntimeChecked }
22
22
import scala .compiletime .summonFrom
@@ -285,8 +285,8 @@ object Predef extends LowPriorityImplicits {
285
285
* @param assertion the expression to test
286
286
* @group assertions
287
287
*/
288
- @ elidable(ASSERTION )
289
- def assert (assertion : Boolean ): Unit = {
288
+ @ elidable(ASSERTION ) @ publicInBinary
289
+ @ targetName( " assert " ) private [scala] def scala2Assert (assertion : Boolean ): Unit = {
290
290
if (! assertion)
291
291
throw new java.lang.AssertionError (" assertion failed" )
292
292
}
@@ -300,12 +300,18 @@ object Predef extends LowPriorityImplicits {
300
300
* @param message a String to include in the failure message
301
301
* @group assertions
302
302
*/
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 = {
305
305
if (! assertion)
306
306
throw new java.lang.AssertionError (" assertion failed: " + message)
307
307
}
308
308
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
+
309
315
/** Tests an expression, throwing an `AssertionError` if false.
310
316
* This method differs from assert only in the intent expressed:
311
317
* assert contains a predicate which needs to be proven, while
0 commit comments