Don't try parsing contract-like function not from kotlin package

Returning `null` from `doCheckContract` functions means that we
have failed to parse contract function and should report an error, but
if the called function isn't true contract, we shouldn't evaluate that code
at all.

 #KT-27758 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2018-10-23 11:23:06 +03:00
committed by Dmitry Savvinov
parent d82ca9ccd0
commit bae3ff5211
5 changed files with 95 additions and 8 deletions
@@ -0,0 +1,42 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
package my
// Accepts block, can't be distinguished from kotlin.contract without resolve
fun contract(block: () -> Unit) {}
// Accepts int, potentially can be distinguished from kotlin.contract by PSI,
// but as of Kotlin 1.3.0, we don't do that
fun contract(i: Int) {}
fun doStuff() {}
class SomeClass {
fun contract() {}
fun callMemberContractWithThis() {
this.contract()
}
fun callMemberContractWithoutThis() {
contract()
}
fun callTopLevelSamePsiInMember() {
contract { }
}
}
fun callTopLevelSamePsi() {
contract { }
}
fun callTopLevelDifferentPsi() {
contract(42)
}
fun callTopLevelSamePsiNotFirstStatement() {
doStuff()
contract { }
}