From e9901e7351b00fe1917b8d2926107df1e34c163b Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 7 Sep 2015 18:57:26 +0300 Subject: [PATCH] Deprecate assert with non-lazy message. #KT-8253 --- libraries/stdlib/src/kotlin/util/AssertionsJVM.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt b/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt index e4210cb2404..c1e17d607a1 100644 --- a/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt +++ b/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt @@ -6,10 +6,19 @@ private object _Assertions deprecated("Must be public to make assert() inlinable") public val ASSERTIONS_ENABLED: Boolean = _Assertions.javaClass.desiredAssertionStatus() +/** + * Throws an [AssertionError] if the [value] is false + * and runtime assertions have been enabled on the JVM using the *-ea* JVM option. + */ +public fun assert(value: Boolean) { + assert(value) { "Assertion failed" } +} + /** * Throws an [AssertionError] with an optional [message] if the [value] is false * and runtime assertions have been enabled on the JVM using the *-ea* JVM option. */ +@deprecated("Use assert with lazy message instead.", ReplaceWith("assert(value) { message }")) public fun assert(value: Boolean, message: Any = "Assertion failed") { if (ASSERTIONS_ENABLED) { if (!value) {