[FIR] KT-56877: Allow referencing implicit receivers in class contracts

This commit is contained in:
Nikolay Lunyak
2023-03-07 13:27:44 +02:00
committed by Space Team
parent 409249267c
commit c7a71fec17
10 changed files with 20 additions and 67 deletions
@@ -10,13 +10,13 @@ class Foo {
inner class Bar {
fun good() {
contract {
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this<!UNRESOLVED_LABEL!>@Bar<!> != null)<!>
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this@Bar != null)<!>
}
}
fun badOuter() {
contract {
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this<!UNRESOLVED_LABEL!>@Foo<!> != null)<!>
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this@Foo != null)<!>
}
}
@@ -34,7 +34,7 @@ class Foo {
fun A?.badWithReceiver() {
contract {
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this<!UNRESOLVED_LABEL!>@Bar<!> != null)<!>
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this@Bar != null)<!>
}
}
}
@@ -7,7 +7,7 @@ import kotlin.contracts.*
class Foo(val x: Int?) {
fun isXNull(): Boolean {
contract {
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns(false) implies (<!UNRESOLVED_REFERENCE!>x<!> != null)<!>
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns(false) implies (x != null)<!>
}
return x != null
}
@@ -7,8 +7,8 @@ import kotlin.contracts.*
class Foo(val x: Int?) {
fun isXNull(): Boolean {
contract {
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns(false) implies (<!UNRESOLVED_REFERENCE!>x<!> != null)<!>
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns(false) implies (x != null)<!>
}
return x != null
}
}
}