Deprecate assert with non-lazy message.
#KT-8253
This commit is contained in:
@@ -6,10 +6,19 @@ private object _Assertions
|
|||||||
deprecated("Must be public to make assert() inlinable")
|
deprecated("Must be public to make assert() inlinable")
|
||||||
public val ASSERTIONS_ENABLED: Boolean = _Assertions.javaClass.desiredAssertionStatus()
|
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
|
* 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.
|
* 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") {
|
public fun assert(value: Boolean, message: Any = "Assertion failed") {
|
||||||
if (ASSERTIONS_ENABLED) {
|
if (ASSERTIONS_ENABLED) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user