[FIR-TEST] Update testdata of old FE contracts tests
This commit is contained in:
Vendored
+42
@@ -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() {
|
||||
<!INAPPLICABLE_CANDIDATE!>contract<!>()
|
||||
}
|
||||
|
||||
fun callTopLevelSamePsiInMember() {
|
||||
contract { }
|
||||
}
|
||||
}
|
||||
|
||||
fun callTopLevelSamePsi() {
|
||||
contract { }
|
||||
}
|
||||
|
||||
fun callTopLevelDifferentPsi() {
|
||||
contract(42)
|
||||
}
|
||||
|
||||
fun callTopLevelSamePsiNotFirstStatement() {
|
||||
doStuff()
|
||||
contract { }
|
||||
}
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
package my
|
||||
|
||||
Vendored
+2
-2
@@ -58,11 +58,11 @@ val topLevelAnonymousFunction = fun (x: Boolean) {
|
||||
|
||||
var topLevelPropertyAccessors: Int? = 42
|
||||
get() {
|
||||
contract { returns() implies (field != null) }
|
||||
contract { returns() implies (<!UNRESOLVED_REFERENCE!>field<!> != null) }
|
||||
return 42
|
||||
}
|
||||
set(value) {
|
||||
contract { returns() implies (field != null) }
|
||||
contract { returns() implies (<!UNRESOLVED_REFERENCE!>field<!> != null) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -73,11 +73,11 @@ val topLevelAnonymousFunction = fun (x: Boolean) {
|
||||
|
||||
var topLevelPropertyAccessors: Int? = 42
|
||||
get() {
|
||||
contract { returns() implies (field != null) }
|
||||
contract { returns() implies (<!UNRESOLVED_REFERENCE!>field<!> != null) }
|
||||
return 42
|
||||
}
|
||||
set(value) {
|
||||
contract { returns() implies (field != null) }
|
||||
contract { returns() implies (<!UNRESOLVED_REFERENCE!>field<!> != null) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -25,9 +25,9 @@ fun whenInContract(x: Any?, boolean: Boolean) {
|
||||
|
||||
fun forInContract(x: Any?) {
|
||||
contract {
|
||||
for (i in 0..1) {
|
||||
<!UNRESOLVED_REFERENCE!>for (i in 0..1) {
|
||||
returns() implies (x is String)
|
||||
}
|
||||
}<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+39
@@ -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 {
|
||||
<!UNRESOLVED_REFERENCE!>s<!> = "hello"
|
||||
}
|
||||
<!UNRESOLVED_REFERENCE!>s<!>.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !LANGUAGE: +UseReturnsEffect
|
||||
// Issue: KT-26386
|
||||
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@ import kotlin.contracts.*
|
||||
class Foo(val x: Int?) {
|
||||
fun isXNull(): Boolean {
|
||||
contract {
|
||||
returns(false) implies (x != null)
|
||||
returns(false) implies (<!UNRESOLVED_REFERENCE!>x<!> != null)
|
||||
}
|
||||
return x != null
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@ import kotlin.contracts.*
|
||||
class Foo(val x: Int?) {
|
||||
fun isXNull(): Boolean {
|
||||
contract {
|
||||
returns(false) implies (x != null)
|
||||
returns(false) implies (<!UNRESOLVED_REFERENCE!>x<!> != null)
|
||||
}
|
||||
return x != null
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import kotlin.contracts.*
|
||||
|
||||
fun test(x: Any?) {
|
||||
if (isString(x)) {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
x.length
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user