[FIR] Properly resolve declarations inside contract calls on CONTRACT phase

This commit is contained in:
Dmitriy Novozhilov
2022-11-11 17:34:14 +02:00
committed by Space Team
parent 01c6c7dc59
commit 9b7b517f43
6 changed files with 29 additions and 54 deletions
@@ -25,7 +25,7 @@ fun whenInContract(x: Any?, boolean: Boolean) {
fun forInContract(x: Any?) {
contract {
for (i in <!HAS_NEXT_MISSING!>0..1<!>) {
for (i in 0..1) {
returns() implies (x is String)
}
}
@@ -52,4 +52,4 @@ fun localValInContract(x: Any?) {
<!ERROR_IN_CONTRACT_DESCRIPTION!>val y: Int = 42<!>
returns() implies (x is String)
}<!>
}
}
@@ -1,39 +0,0 @@
// !OPT_IN: kotlin.contracts.ExperimentalContracts
// !LANGUAGE: +UseReturnsEffect
// Issue: KT-26386
fun myRun(block: () -> Unit) {
block()
}
fun contract(block: () -> Unit) {
block()
}
fun case_1(): Boolean? {
contract { case_1() }
return null
}
fun case_2(): Boolean? {
contract { case_3() }
return null
}
fun case_3(): Boolean? {
contract { case_2() }
return null
}
fun case4() {
contract {
myRun {
val s: String
run {
<!UNRESOLVED_REFERENCE!>s<!> = "hello"
}
<!UNRESOLVED_REFERENCE!>s<!>.length
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !OPT_IN: kotlin.contracts.ExperimentalContracts
// !LANGUAGE: +UseReturnsEffect
// Issue: KT-26386