Fix recursion in contract declaration analysis. KT-26386 Fixed

Issue fixed only in old inference
This commit is contained in:
Dmitriy Novozhilov
2019-03-07 14:13:28 +03:00
parent d0462859bf
commit 77c98bef4d
13 changed files with 137 additions and 14 deletions
@@ -0,0 +1,25 @@
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !LANGUAGE: +UseReturnsEffect
// Issue: KT-26386
import kotlin.contracts.*
fun case_1(): Boolean {
contract { returns(null) implies <!ERROR_IN_CONTRACT_DESCRIPTION!>case_1()<!> }
return true
}
fun case_2(): Boolean {
contract { returns(null) implies <!ERROR_IN_CONTRACT_DESCRIPTION!>case_3()<!> }
return true
}
fun case_3(): Boolean {
contract { returns(null) implies <!ERROR_IN_CONTRACT_DESCRIPTION!>case_2()<!> }
return true
}
fun case_4(): Boolean {
kotlin.contracts.contract { returns(null) implies <!ERROR_IN_CONTRACT_DESCRIPTION!>case_1()<!> }
return true
}
@@ -0,0 +1,6 @@
package
public fun case_1(): kotlin.Boolean
public fun case_2(): kotlin.Boolean
public fun case_3(): kotlin.Boolean
public fun case_4(): kotlin.Boolean
@@ -0,0 +1,39 @@
// !USE_EXPERIMENTAL: 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 {
s = "hello"
}
s.length
}
}
}
@@ -0,0 +1,8 @@
package
public fun case4(): kotlin.Unit
public fun case_1(): kotlin.Boolean?
public fun case_2(): kotlin.Boolean?
public fun case_3(): kotlin.Boolean?
public fun contract(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public fun myRun(/*0*/ block: () -> kotlin.Unit): kotlin.Unit