[FIR] Add resolution of contracts that are written using the new syntax

This commit is contained in:
Arsen Nagdalian
2020-07-27 18:40:41 +03:00
parent b8b60864fd
commit ede1c08a9b
4 changed files with 171 additions and 14 deletions
@@ -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
}
@@ -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)
}