1/2 analysis-api: Initial implementation for contracts
Review: https://jetbrains.team/p/kt/reviews/7652 I need this API for KTIJ-22692
This commit is contained in:
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_STDLIB
|
||||
// DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE_K1
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
|
||||
class Foo
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun isInstancePredicateContract(value: Any) {
|
||||
contr<caret>act {
|
||||
returns() implies (value is Foo)
|
||||
}
|
||||
if (value !is Foo) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user