Add contract to checkNotNull overload without message
^KT-25303 Fixed
This commit is contained in:
+7
-2
@@ -22,7 +22,12 @@ fun testCheckWithFailingMessage(x: Any?) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
|
||||
fun tesCheckNotNullWithMessage(x: Int?) {
|
||||
checkNotNull(x) { "x is null!"}
|
||||
fun testCheckNotNullWithMessage(x: Int?) {
|
||||
checkNotNull(x) { "x is null!" }
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.inc()
|
||||
}
|
||||
|
||||
fun testCheckNotNull(x: Int?) {
|
||||
checkNotNull(x)
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.inc()
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package
|
||||
|
||||
public fun tesCheckNotNullWithMessage(/*0*/ x: kotlin.Int?): kotlin.Unit
|
||||
public fun testCheckNotNull(/*0*/ x: kotlin.Int?): kotlin.Unit
|
||||
public fun testCheckNotNullWithMessage(/*0*/ x: kotlin.Int?): kotlin.Unit
|
||||
public fun testCheckSmartcast(/*0*/ x: kotlin.Any?): kotlin.Unit
|
||||
public fun testCheckUnreachableCode(): kotlin.Unit
|
||||
public fun testCheckWithFailingMessage(/*0*/ x: kotlin.Any?): kotlin.Unit
|
||||
|
||||
@@ -106,7 +106,12 @@ public inline fun check(value: Boolean, lazyMessage: () -> Any): Unit {
|
||||
* @sample samples.misc.Preconditions.failCheckWithLazyMessage
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T : Any> checkNotNull(value: T?): T = checkNotNull(value) { "Required value was null." }
|
||||
public inline fun <T : Any> checkNotNull(value: T?): T {
|
||||
contract {
|
||||
returns() implies (value != null)
|
||||
}
|
||||
return checkNotNull(value) { "Required value was null." }
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an [IllegalStateException] with the result of calling [lazyMessage] if the [value] is null. Otherwise
|
||||
|
||||
Reference in New Issue
Block a user