[FIR] Add resolution of contracts that are written using the new syntax
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
import kotlin.contracts.*
|
||||
|
||||
fun test1(arg: Any?) contract [
|
||||
returns() implies (arg != null)
|
||||
] {
|
||||
require(arg != null)
|
||||
}
|
||||
|
||||
fun test2(s: String?, block: () -> Unit) contract [
|
||||
returns() implies (s != null),
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
] {
|
||||
require(s != null)
|
||||
block()
|
||||
}
|
||||
|
||||
fun test3(arg: Any?): Boolean contract [
|
||||
returns(true) implies (arg != null)
|
||||
] {
|
||||
require(arg != null)
|
||||
return true
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
FILE: functionsWithContract.kt
|
||||
public final fun test1(arg: R|kotlin/Any?|): R|kotlin/Unit|
|
||||
[R|Contract description]
|
||||
<
|
||||
Returns(WILDCARD) -> arg != null
|
||||
>
|
||||
{
|
||||
R|kotlin/require|(!=(R|<local>/arg|, Null(null)))
|
||||
}
|
||||
public final fun test2(s: R|kotlin/String?|, block: R|() -> kotlin/Unit|): R|kotlin/Unit|
|
||||
[R|Contract description]
|
||||
<
|
||||
Returns(WILDCARD) -> s != null
|
||||
CallsInPlace(block, EXACTLY_ONCE)
|
||||
>
|
||||
{
|
||||
R|kotlin/require|(!=(R|<local>/s|, Null(null)))
|
||||
R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
|
||||
}
|
||||
public final fun test3(arg: R|kotlin/Any?|): R|kotlin/Boolean|
|
||||
[R|Contract description]
|
||||
<
|
||||
Returns(TRUE) -> arg != null
|
||||
>
|
||||
{
|
||||
R|kotlin/require|(!=(R|<local>/arg|, Null(null)))
|
||||
^test3 Boolean(true)
|
||||
}
|
||||
Reference in New Issue
Block a user