Deprecate assert with non-lazy message.

#KT-8253
This commit is contained in:
Ilya Gorbunov
2015-09-07 18:57:26 +03:00
parent 470fcc977c
commit e9901e7351
@@ -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) {