Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/contracts/genericContract.kt
T
2021-04-16 17:23:22 +03:00

26 lines
526 B
Kotlin
Vendored

// WITH_STDLIB
import kotlin.contracts.*
inline fun <reified T> requreIsInstance(value: Any) contract [
returns() implies (value is T)
] {
if (value !is T) throw IllegalArgumentException()
}
fun test_1(s: Any) {
requreIsInstance<String>(s)
s.length
}
inline fun <reified T> requreIsInstanceOf(value: Any, requiredValue: T) contract [
returns() implies (value is T)
] {
if (value !is T) throw IllegalArgumentException()
}
fun test_2(x: Any, s: String) {
requreIsInstanceOf(x, s)
x.length
}