[LL FIR] add script tests for AbstractInBlockModificationTest

^KT-60728
This commit is contained in:
Dmitrii Gridin
2023-07-27 16:42:04 +02:00
parent 576f6642f9
commit a60abc6c06
151 changed files with 1052 additions and 6 deletions
@@ -0,0 +1,27 @@
class Builder {
var version: String = ""
fun execute() {
println(version)
}
}
fun build(action: Builder.() -> Unit) = Builder().apply(action)
build {
version = "123"
class A {
fun doo() {
}
}
execute()
}
val builder = build {
version = "321"
}
builder.execute()
builder.version = <expr>""</expr>
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,9 @@
import kotlin.contracts.InvocationKind
inline fun foo(block: () -> Unit) {
kotlin.contracts.contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
<expr>block()</expr>
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,9 @@
import kotlin.contracts.InvocationKind
inline fun foo(block: () -> Unit) {
<expr>kotlin.contracts.contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}</expr>
block()
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,3 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtBlockExpression
fun doo() <expr>{}</expr>
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,4 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtBlockExpression
val i: Int
get() <expr>{}</expr>
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,3 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtConstantExpression
val i: Int = <expr>42</expr>
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,4 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtBlockExpression
var i: Int = 4
set(value) <expr>{}</expr>
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,7 @@
class MyProducer {
fun produce(): Int = 4
}
fun MyProducer.testFun(param1: Int = produce()) {
<expr>42</expr>
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,5 @@
fun testFun(param1: Int, param2: String = "str", param3: List<Int> = myList()) {
<expr>42</expr>
}
fun myList(): List<Int>
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,9 @@
import kotlin.contracts.InvocationKind
inline fun foo(block: () -> Unit) {
kotlin.contracts.contract {
<expr>callsInPlace</expr>(block, InvocationKind.EXACTLY_ONCE)
}
block()
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,7 @@
class MyProducer {
fun produce(): Int = 4
}
fun MyProducer.testFun(param1: Int = <expr>produce</expr>()) {
42
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,26 @@
class Builder {
var version: String = ""
fun execute() {
println(version)
}
}
fun build(action: Builder.() -> Unit) = Builder().apply(action)
build {
<expr>version</expr> = "123"
class A {
fun doo() {
}
}
execute()
}
val builder = build {
version = "321"
}
builder.execute()
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,13 @@
import kotlin.contracts.contract
class A {
fun x() {
contract {
req
}
val a = <expr>doSmth("str")</expr>
}
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,10 @@
import kotlin.contracts.*
class A {
fun passLambdaValue(l: ContractBuilder.() -> Unit) {
contract(l)
<expr>42</expr>
}
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,11 @@
class A {
fun x() {
contract {
req
}
val <expr>a</expr> = doSmth("str")
}
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,7 @@
class A {
fun x(): Int {
return <expr>doSmth</expr>("str")
}
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,7 @@
class A {
fun x() {
val <expr>a</expr> = doSmth("str")
}
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,7 @@
class A {
fun () {
val <expr>a</expr> = doSmth("str")
}
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,5 @@
class A {
fun x(): Int = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,5 @@
class A {
fun (): Int = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,5 @@
class A {
fun () = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,5 @@
class A {
fun x() = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,14 @@
import kotlin.contracts.contract
class A {
var x: Int
get() {
contract {
req
}
fun <expr>doSmth</expr>(i: String) = 4
return doSmth("str")
}
set(value) = Unit
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,14 @@
import kotlin.contracts.contract
class A {
var : Int
get() {
contract {
req
}
fun <expr>doSmth</expr>(i: String) = 4
return doSmth("str")
}
set(value) = Unit
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,7 @@
class A {
val x: Int
get() {
fun doSmth(i: String) = <expr>4</expr>
return doSmth("str")
}
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,5 @@
class A {
val x: Int get() = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,5 @@
class A {
val : Int get() = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,8 @@
class A {
val x
get() {
return <expr>doSmth</expr>("str")
}
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,5 @@
class A {
val x get() = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,6 @@
class A {
val x: Int by lazy {
fun <expr>doSmth</expr>(i: String) = 4
doSmth("str")
}
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,6 @@
class A {
val : Int by lazy {
fun doSmth(i: String) = 4
<expr>doSmth</expr>("str")
}
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,3 @@
class A {
val x: Int by <expr>ErrorDelegate</expr>()
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,6 @@
class A {
val x: Int = run {
fun doSmth(i: String) = 4
<expr>doSmth</expr>("str")
}
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,6 @@
class A {
val : Int = run {
fun doSmth(i: String) = 4
<expr>doSmth</expr>("str")
}
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,6 @@
class A {
val x by lazy {
fun doSmth(i: String) = 4
<expr>doSmth</expr>("str")
}
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,3 @@
class A {
val x by <expr>ErrorDelegate</expr>()
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,5 @@
class A {
val x = run {
<expr>doSmth</expr>("str")
}
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,8 @@
class A {
var x: Int = 1
set(value) {
<expr>doSmth</expr>(value)
}
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,8 @@
class A {
var : Int = 1
set(value) {
<expr>doSmth</expr>(value)
}
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,6 @@
class A {
var x: Int = 1
set(value) = <expr>doSmth</expr>(value)
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,6 @@
class A {
var : Int = 1
set(value) = <expr>doSmth</expr>(value)
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,9 @@
class A {
var x
get() = 1
set(value) {
<expr>doSmth</expr>(value)
}
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,7 @@
class A {
var x
get() = 1
set(value) = <expr>doSmth</expr>(value)
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,9 @@
fun foo(arg: Any?, num: Int?, block: () -> Unit) contract [
returns() implies (arg is String),
returns() implies (num != null),
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
] {
require(arg is String)
require(num != null)
<expr>block</expr>()
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,26 @@
class Builder {
var version: String = ""
fun execute() {
println(version)
}
}
fun build(action: Builder.() -> Unit) = Builder().apply(action)
build {
version = "123"
class A {
fun doo() {
}
}
execute()
}
val builder = build {
version = "321"
}
builder.<expr>execute</expr>()
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,26 @@
class Builder {
var version: String = ""
fun execute() {
println(version)
}
}
fun build(action: Builder.() -> Unit) = Builder().apply(action)
build {
version = "123"
class A {
fun doo() {
}
}
execute()
}
val builder = <expr>build</expr> {
version = "321"
}
builder.execute()
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,5 @@
fun () {
val a = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,5 @@
fun foo(): Int {
return <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,3 @@
fun foo(): Int = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,3 @@
fun (): Int = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE

Some files were not shown because too many files have changed in this diff Show More