[FIR] KT-56877: Allow referencing implicit receivers in class contracts
This commit is contained in:
committed by
Space Team
parent
409249267c
commit
c7a71fec17
+7
-7
@@ -11,16 +11,16 @@ object case_1 {
|
||||
private const val value_3 = false
|
||||
|
||||
fun case_1_1(): Boolean? {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returnsNotNull() implies (<!UNRESOLVED_REFERENCE!>value_1<!>)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returnsNotNull() implies (value_1)<!> }
|
||||
return if (value_1) true else null
|
||||
}
|
||||
fun case_1_2(): Boolean? {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(null) implies (<!UNRESOLVED_REFERENCE!>value_2<!>)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(null) implies (value_2)<!> }
|
||||
return if (value_2) null else true
|
||||
}
|
||||
|
||||
fun case_1_3(): Boolean {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (<!UNRESOLVED_REFERENCE!>value_3<!>)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (value_3)<!> }
|
||||
return value_3
|
||||
}
|
||||
}
|
||||
@@ -42,22 +42,22 @@ class case_2(value_5: Boolean, val value_1: Boolean) {
|
||||
}
|
||||
|
||||
fun case_2_2(): Boolean? {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(null) implies (<!UNRESOLVED_REFERENCE!>value_1<!>)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(null) implies (value_1)<!> }
|
||||
return if (value_1) null else true
|
||||
}
|
||||
|
||||
fun case_2_3(): Boolean {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (<!UNRESOLVED_REFERENCE!>value_2<!>)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (value_2)<!> }
|
||||
return value_2
|
||||
}
|
||||
|
||||
fun case_2_4(): Boolean {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(false) implies (<!UNRESOLVED_REFERENCE!>value_3<!>)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(false) implies (value_3)<!> }
|
||||
return !(value_3)
|
||||
}
|
||||
|
||||
inline fun <reified K : Number> K.case_2_5(): Boolean? {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returnsNotNull() implies (<!UNRESOLVED_REFERENCE!>value_4<!>)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returnsNotNull() implies (<!NON_PUBLIC_CALL_FROM_PUBLIC_INLINE!>value_4<!>)<!> }
|
||||
return if (<!NON_PUBLIC_CALL_FROM_PUBLIC_INLINE!>value_4<!>) true else null
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@ fun case_2() {
|
||||
class case_4 : ClassLevel3() {
|
||||
|
||||
fun <T : Number?>T.case_4_1(): Boolean {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(false) implies (this<!UNRESOLVED_LABEL!>@case_4<!> !is ClassLevel1)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(false) implies (<!USELESS_IS_CHECK!>this@case_4 !is ClassLevel1<!>)<!> }
|
||||
return this == null
|
||||
}
|
||||
|
||||
@@ -60,12 +60,12 @@ class case_4 : ClassLevel3() {
|
||||
class case_5<T> : ClassLevel5() {
|
||||
inner class case_5_1 {
|
||||
fun <K : Number?>K.case_5_1_1() {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this<!UNRESOLVED_LABEL!>@case_5_1<!> !is ClassLevel1 && this<!UNRESOLVED_LABEL!>@case_5_1<!> != null || this<!UNRESOLVED_LABEL!>@case_5<!> is ClassLevel1 && this@case_5_1_1 is Float)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this@case_5_1 !is ClassLevel1 && <!SENSELESS_COMPARISON!>this@case_5_1 != null<!> || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> && this@case_5_1_1 is Float)<!> }
|
||||
if (!(this@case_5_1 !is ClassLevel1 && <!SENSELESS_COMPARISON!>this@case_5_1 != null<!> || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> && this is Float)) throw Exception()
|
||||
}
|
||||
|
||||
fun case_5_1_2() {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this<!UNRESOLVED_LABEL!>@case_5_1<!> !is ClassLevel1 || this<!UNRESOLVED_LABEL!>@case_5<!> is ClassLevel1 || this<!UNRESOLVED_LABEL!>@case_5_1<!> == null)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this@case_5_1 !is ClassLevel1 || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> || <!SENSELESS_COMPARISON!>this@case_5_1 == null<!>)<!> }
|
||||
if (!(this@case_5_1 !is ClassLevel1 || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> || <!SENSELESS_COMPARISON!>this@case_5_1 == null<!>)) throw Exception()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user