// LANGUAGE: -ContractSyntaxV2 // WITH_STDLIB import kotlin.contracts.* inline fun requreIsInstance(value: Any) contract [ returns() implies (value is T) ] { if (value !is T) throw IllegalArgumentException() } val Any?.myLength: Int? get() contract [ returnsNotNull() implies (this@length is String) ] = (this as? String)?.length fun test_1(x: Any) { requreIsInstance(x) x.length } fun test_2(x: Any) { if (x.myLength != null) { x.length } }