Add contract to checkNotNull overload without message

^KT-25303 Fixed
This commit is contained in:
Dmitry Savvinov
2018-07-26 13:32:29 +03:00
parent 952f67dafc
commit a81fc9e9bc
3 changed files with 15 additions and 4 deletions
@@ -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