Drop deprecations: preconditions with non-lazy message.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
ERR:
|
ERR:
|
||||||
java.lang.IllegalStateException: my error
|
java.lang.IllegalStateException: my error
|
||||||
at kotlin.PreconditionsKt__PreconditionsKt.error(Preconditions.kt:142)
|
at kotlin.PreconditionsKt__PreconditionsKt.error(Preconditions.kt:88)
|
||||||
at kotlin.PreconditionsKt.error(Unknown Source)
|
at kotlin.PreconditionsKt.error(Unknown Source)
|
||||||
at Script.main(Unknown Source)
|
at Script.main(Unknown Source)
|
||||||
at Script.a(Unknown Source)
|
at Script.a(Unknown Source)
|
||||||
|
|||||||
@@ -16,20 +16,6 @@ public fun assert(value: Boolean) {
|
|||||||
assert(value) { "Assertion failed" }
|
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 }"), DeprecationLevel.ERROR)
|
|
||||||
public fun assert(value: Boolean, message: Any = "Assertion failed") {
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
if (ASSERTIONS_ENABLED) {
|
|
||||||
if (!value) {
|
|
||||||
throw AssertionError(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws an [AssertionError] calculated by [lazyMessage] if the [value] is false
|
* Throws an [AssertionError] calculated by [lazyMessage] 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.
|
||||||
|
|||||||
@@ -11,18 +11,6 @@ import java.lang.IllegalStateException
|
|||||||
*/
|
*/
|
||||||
public fun require(value: Boolean): Unit = require(value) { "Failed requirement" }
|
public fun require(value: Boolean): Unit = require(value) { "Failed requirement" }
|
||||||
|
|
||||||
/**
|
|
||||||
* Throws an [IllegalArgumentException] with an optional [message] if the [value] is false.
|
|
||||||
*
|
|
||||||
* @sample test.collections.PreconditionsTest.failingRequireWithMessage
|
|
||||||
*/
|
|
||||||
@Deprecated("Use require with lazy message instead.", ReplaceWith("require(value) { message }"), DeprecationLevel.ERROR)
|
|
||||||
public fun require(value: Boolean, message: Any = "Failed requirement"): Unit {
|
|
||||||
if (!value) {
|
|
||||||
throw IllegalArgumentException(message.toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws an [IllegalArgumentException] with the result of calling [lazyMessage] if the [value] is false.
|
* Throws an [IllegalArgumentException] with the result of calling [lazyMessage] if the [value] is false.
|
||||||
*
|
*
|
||||||
@@ -40,21 +28,6 @@ public inline fun require(value: Boolean, lazyMessage: () -> Any): Unit {
|
|||||||
*/
|
*/
|
||||||
public fun <T:Any> requireNotNull(value: T?): T = requireNotNull(value) { "Required value was null" }
|
public fun <T:Any> requireNotNull(value: T?): T = requireNotNull(value) { "Required value was null" }
|
||||||
|
|
||||||
/**
|
|
||||||
* Throws an [IllegalArgumentException] with the given [message] if the [value] is null. Otherwise
|
|
||||||
* returns the not null value.
|
|
||||||
*
|
|
||||||
* @sample test.collections.PreconditionsTest.requireNotNull
|
|
||||||
*/
|
|
||||||
@Deprecated("Use requireNotNull with lazy message instead.", ReplaceWith("requireNotNull(value) { message }"), DeprecationLevel.ERROR)
|
|
||||||
public fun <T:Any> requireNotNull(value: T?, message: Any = "Required value was null"): T {
|
|
||||||
if (value == null) {
|
|
||||||
throw IllegalArgumentException(message.toString())
|
|
||||||
} else {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws an [IllegalArgumentException] with the result of calling [lazyMessage] if the [value] is null. Otherwise
|
* Throws an [IllegalArgumentException] with the result of calling [lazyMessage] if the [value] is null. Otherwise
|
||||||
* returns the not null value.
|
* returns the not null value.
|
||||||
@@ -75,18 +48,6 @@ public inline fun <T:Any> requireNotNull(value: T?, lazyMessage: () -> Any): T {
|
|||||||
*/
|
*/
|
||||||
public fun check(value: Boolean): Unit = check(value) { "Check failed" }
|
public fun check(value: Boolean): Unit = check(value) { "Check failed" }
|
||||||
|
|
||||||
/**
|
|
||||||
* Throws an [IllegalStateException] with an optional [message] if the [value] is false.
|
|
||||||
*
|
|
||||||
* @sample test.collections.PreconditionsTest.failingCheckWithMessage
|
|
||||||
*/
|
|
||||||
@Deprecated("Use check with lazy message instead.", ReplaceWith("check(value) { message }"), DeprecationLevel.ERROR)
|
|
||||||
public fun check(value: Boolean, message: Any = "Check failed"): Unit {
|
|
||||||
if (!value) {
|
|
||||||
throw IllegalStateException(message.toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws an [IllegalStateException] with the result of calling [lazyMessage] if the [value] is false.
|
* Throws an [IllegalStateException] with the result of calling [lazyMessage] if the [value] is false.
|
||||||
*
|
*
|
||||||
@@ -105,21 +66,6 @@ public inline fun check(value: Boolean, lazyMessage: () -> Any): Unit {
|
|||||||
*/
|
*/
|
||||||
public fun <T:Any> checkNotNull(value: T?): T = checkNotNull(value) { "Required value was null" }
|
public fun <T:Any> checkNotNull(value: T?): T = checkNotNull(value) { "Required value was null" }
|
||||||
|
|
||||||
/**
|
|
||||||
* Throws an [IllegalStateException] with the given [message] if the [value] is null. Otherwise
|
|
||||||
* returns the not null value.
|
|
||||||
*
|
|
||||||
* @sample test.collections.PreconditionsTest.checkNotNull
|
|
||||||
*/
|
|
||||||
@Deprecated("Use checkNotNull with lazy message instead.", ReplaceWith("checkNotNull(value) { message }"), DeprecationLevel.ERROR)
|
|
||||||
public fun <T:Any> checkNotNull(value: T?, message: Any = "Required value was null"): T {
|
|
||||||
if (value == null) {
|
|
||||||
throw IllegalStateException(message.toString())
|
|
||||||
} else {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws an [IllegalStateException] with the result of calling [lazyMessage] if the [value] is null. Otherwise
|
* Throws an [IllegalStateException] with the result of calling [lazyMessage] if the [value] is null. Otherwise
|
||||||
* returns the not null value.
|
* returns the not null value.
|
||||||
|
|||||||
Reference in New Issue
Block a user