[FIR] KT-56877: Allow referencing implicit receivers in class contracts
This commit is contained in:
committed by
Space Team
parent
409249267c
commit
c7a71fec17
Vendored
-42
@@ -1,42 +0,0 @@
|
||||
// !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() {
|
||||
<!NONE_APPLICABLE!>contract<!>()
|
||||
}
|
||||
|
||||
fun callTopLevelSamePsiInMember() {
|
||||
contract { }
|
||||
}
|
||||
}
|
||||
|
||||
fun callTopLevelSamePsi() {
|
||||
contract { }
|
||||
}
|
||||
|
||||
fun callTopLevelDifferentPsi() {
|
||||
contract(42)
|
||||
}
|
||||
|
||||
fun callTopLevelSamePsiNotFirstStatement() {
|
||||
doStuff()
|
||||
contract { }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
package my
|
||||
|
||||
Vendored
+3
-3
@@ -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)<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user