[LL FIR] AbstractInBlockModificationTest: cover getNonLocalReanalyzableContainingDeclaration

^KT-60518
This commit is contained in:
Dmitrii Gridin
2023-07-18 15:23:56 +02:00
committed by Space Team
parent c2fd245ca1
commit f0d8a1cbe9
84 changed files with 126 additions and 117 deletions
@@ -1,9 +1,9 @@
import kotlin.contracts.InvocationKind
inline fun f<caret>oo(block: () -> Unit) {
inline fun foo(block: () -> Unit) {
kotlin.contracts.contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
block()
<expr>block()</expr>
}
@@ -2,6 +2,6 @@ class MyProducer {
fun produce(): Int = 4
}
fun MyProducer.test<caret>Fun(param1: Int = produce()) {
fun MyProducer.testFun(param1: Int = produce()) {
<expr>42</expr>
}
@@ -1,5 +1,6 @@
BEFORE MODIFICATION:
public final [ResolvedTo(BODY_RESOLVE)] fun R|MyProducer|.testFun([ResolvedTo(BODY_RESOLVE)] param1: R|kotlin/Int| = this@R|/testFun|.R|/MyProducer.produce|()): R|kotlin/Unit| {
Int(42)
}
AFTER MODIFICATION:
@@ -1,5 +1,5 @@
fun test<caret>Fun(param1: Int, param2: String = "str", param3: List<Int> = myList()) {
fun testFun(param1: Int, param2: String = "str", param3: List<Int> = myList()) {
<expr>42</expr>
}
fun myList(): List<Int>
@@ -1,5 +1,6 @@
BEFORE MODIFICATION:
public final [ResolvedTo(BODY_RESOLVE)] fun testFun([ResolvedTo(BODY_RESOLVE)] param1: R|kotlin/Int|, [ResolvedTo(BODY_RESOLVE)] param2: R|kotlin/String| = String(str), [ResolvedTo(BODY_RESOLVE)] param3: R|kotlin/collections/List<kotlin/Int>| = R|/myList|()): R|kotlin/Unit| {
Int(42)
}
AFTER MODIFICATION:
@@ -1,12 +1,12 @@
import kotlin.contracts.contract
class A {
fun <caret>x() {
fun x() {
contract {
req
}
val a = doSmth("str")
val a = <expr>doSmth("str")</expr>
}
}
@@ -1,8 +1,9 @@
import kotlin.contracts.*
class A {
fun passLa<caret>mbdaValue(l: ContractBuilder.() -> Unit) {
fun passLambdaValue(l: ContractBuilder.() -> Unit) {
contract(l)
<expr>42</expr>
}
}
@@ -8,6 +8,7 @@ public final [ResolvedTo(BODY_RESOLVE)] fun passLambdaValue([ResolvedTo(BODY_RES
contract#(l#)
}
Int(42)
}
AFTER MODIFICATION:
@@ -8,6 +8,7 @@ public final [ResolvedTo(BODY_RESOLVE)] fun passLambdaValue([ResolvedTo(BODY_RES
R|kotlin/contracts/contract|(R|<local>/l|)
}
Int(42)
}
AFTER MODIFICATION:
@@ -1,10 +1,10 @@
class A {
fun <caret>x() {
fun x() {
contract {
req
}
val a = doSmth("str")
val <expr>a</expr> = doSmth("str")
}
}
@@ -1,6 +1,6 @@
class A {
fun <caret>x(): Int {
return doSmth("str")
fun x(): Int {
return <expr>doSmth</expr>("str")
}
}
@@ -1,6 +1,6 @@
class A {
fun <caret>x() {
val a = doSmth("str")
fun x() {
val <expr>a</expr> = doSmth("str")
}
}
@@ -1,6 +1,6 @@
class A {
fun <caret>() {
val a = doSmth("str")
fun () {
val <expr>a</expr> = doSmth("str")
}
}
@@ -1,5 +1,5 @@
class A {
fun <caret>x(): Int = doSmth("str")
fun x(): Int = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -1,5 +1,5 @@
class A {
fun <caret>(): Int = doSmth("str")
fun (): Int = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -1,5 +1,5 @@
class A {
fun <caret>() = doSmth("str")
fun () = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtNamedFunction DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,5 +1,5 @@
class A {
fun <caret>x() = doSmth("str")
fun x() = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtNamedFunction DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -2,12 +2,12 @@ import kotlin.contracts.contract
class A {
var x: Int
ge<caret>t() {
get() {
contract {
req
}
fun doSmth(i: String) = 4
fun <expr>doSmth</expr>(i: String) = 4
return doSmth("str")
}
set(value) = Unit
@@ -2,12 +2,12 @@ import kotlin.contracts.contract
class A {
var : Int
ge<caret>t() {
get() {
contract {
req
}
fun doSmth(i: String) = 4
fun <expr>doSmth</expr>(i: String) = 4
return doSmth("str")
}
set(value) = Unit
@@ -1,7 +1,7 @@
class A {
val x: Int
ge<caret>t() {
fun doSmth(i: String) = 4
get() {
fun doSmth(i: String) = <expr>4</expr>
return doSmth("str")
}
}
@@ -1,5 +1,5 @@
class A {
val x: Int ge<caret>t() = doSmth("str")
val x: Int get() = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -1,5 +1,5 @@
class A {
val : Int ge<caret>t() = doSmth("str")
val : Int get() = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -1,7 +1,7 @@
class A {
val x
g<caret>et() {
return doSmth("str")
get() {
return <expr>doSmth</expr>("str")
}
}
@@ -1,5 +1,5 @@
class A {
val x ge<caret>t() = doSmth("str")
val x get() = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtPropertyAccessor DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,6 +1,6 @@
class A {
val <caret>x: Int by lazy {
fun doSmth(i: String) = 4
val x: Int by lazy {
fun <expr>doSmth</expr>(i: String) = 4
doSmth("str")
}
}
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtProperty DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,6 +1,6 @@
class A {
val <caret>: Int by lazy {
val : Int by lazy {
fun doSmth(i: String) = 4
doSmth("str")
<expr>doSmth</expr>("str")
}
}
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtProperty DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,3 +1,3 @@
class A {
val <caret>x: Int by ErrorDelegate()
val x: Int by <expr>ErrorDelegate</expr>()
}
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtProperty DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,6 +1,6 @@
class A {
val x<caret>: Int = run {
val x: Int = run {
fun doSmth(i: String) = 4
doSmth("str")
<expr>doSmth</expr>("str")
}
}
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtProperty DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,6 +1,6 @@
class A {
val <caret>: Int = run {
val : Int = run {
fun doSmth(i: String) = 4
doSmth("str")
<expr>doSmth</expr>("str")
}
}
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtProperty DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,6 +1,6 @@
class A {
val <caret>x by lazy {
val x by lazy {
fun doSmth(i: String) = 4
doSmth("str")
<expr>doSmth</expr>("str")
}
}
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtProperty DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,3 +1,3 @@
class A {
val <caret>x by ErrorDelegate()
val x by <expr>ErrorDelegate</expr>()
}
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtProperty DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,5 +1,5 @@
class A {
val x<caret> = run {
doSmth("str")
val x = run {
<expr>doSmth</expr>("str")
}
}
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtProperty DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,7 +1,7 @@
class A {
var x: Int = 1
se<caret>t(value) {
doSmth(value)
set(value) {
<expr>doSmth</expr>(value)
}
}
@@ -1,7 +1,7 @@
class A {
var : Int = 1
se<caret>t(value) {
doSmth(value)
set(value) {
<expr>doSmth</expr>(value)
}
}
@@ -1,6 +1,6 @@
class A {
var x: Int = 1
se<caret>t(value) = doSmth(value)
set(value) = <expr>doSmth</expr>(value)
}
fun doSmth(i: String) = 4
@@ -1,6 +1,6 @@
class A {
var : Int = 1
se<caret>t(value) = doSmth(value)
set(value) = <expr>doSmth</expr>(value)
}
fun doSmth(i: String) = 4
@@ -1,8 +1,8 @@
class A {
var x
get() = 1
s<caret>et(value) {
doSmth(value)
set(value) {
<expr>doSmth</expr>(value)
}
}
@@ -1,7 +1,7 @@
class A {
var x
get() = 1
s<caret>et(value) = doSmth(value)
set(value) = <expr>doSmth</expr>(value)
}
fun doSmth(i: String) = 4
@@ -1,9 +1,9 @@
fun fo<caret>o(arg: Any?, num: Int?, block: () -> Unit) contract [
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)
block()
<expr>block</expr>()
}
@@ -1,5 +1,5 @@
fun <caret>() {
val a = doSmth("str")
fun () {
val a = <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -1,5 +1,5 @@
fun fo<caret>o(): Int {
return doSmth("str")
fun foo(): Int {
return <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -1,3 +1,3 @@
fun f<caret>oo(): Int = doSmth("str")
fun foo(): Int = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -1,3 +1,3 @@
fun <caret>(): Int = doSmth("str")
fun (): Int = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -1,3 +1,3 @@
fun <caret>() = doSmth("str")
fun () = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtNamedFunction DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,5 +1,5 @@
fun f<caret>oo() {
doSmth("str")
fun foo() {
<expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -1,3 +1,3 @@
fun fo<caret>o() = doSmth("str")
fun foo() = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtNamedFunction DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,5 +1,5 @@
val x: Int
ge<caret>t() {
get() {
fun doSmth(i: String) = 4
return doSmth("str")
return <expr>doSmth</expr>("str")
}
@@ -1,5 +1,5 @@
val : Int
ge<caret>t() {
get() {
fun doSmth(i: String) = 4
return doSmth("str")
return <expr>doSmth</expr>("str")
}
@@ -1,3 +1,3 @@
val x: Int g<caret>et() = doSmth("str")
val x: Int get() = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -1,3 +1,3 @@
val : Int g<caret>et() = doSmth("str")
val : Int get() = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -1,6 +1,6 @@
val x
g<caret>et() {
return doSmth("str")
get() {
return <expr>doSmth</expr>("str")
}
fun doSmth(i: String) = 4
@@ -1,3 +1,3 @@
val x get<caret>() = doSmth("str")
val x get() = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtPropertyAccessor DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,4 +1,4 @@
val x<caret>: Int by lazy {
val x: Int by lazy {
fun doSmth(i: String) = 4
doSmth("str")
<expr>doSmth</expr>("str")
}
@@ -1,4 +1,4 @@
val <caret>: Int by lazy {
val : Int by lazy {
fun doSmth(i: String) = 4
doSmth("str")
<expr>doSmth</expr>("str")
}
@@ -1 +1 @@
val x<caret>: Int by ErrorDelegate()
val x: Int by <expr>ErrorDelegate</expr>()
@@ -1,3 +1,3 @@
val <caret>x: Int = doSmth("str")
val x: Int = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -1,3 +1,3 @@
val <caret>: Int = doSmth("str")
val : Int = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -1,4 +1,4 @@
val x<caret> by lazy {
val x by lazy {
fun doSmth(i: String) = 4
doSmth("str")
<expr>doSmth</expr>("str")
}
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtProperty DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1 +1 @@
val x<caret> by ErrorDelegate()
val x by <expr>ErrorDelegate</expr>()
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtProperty DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,3 +1,3 @@
val x<caret> = doSmth("str")
val x = <expr>doSmth</expr>("str")
fun doSmth(i: String) = 4
@@ -1 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS KtProperty DECLARATION
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -1,6 +1,6 @@
var x: Int = 1
se<caret>t(value) {
doSmth(value)
set(value) {
<expr>doSmth</expr>(value)
}
fun doSmth(i: String): Unit = 4
@@ -1,6 +1,6 @@
var : Int = 1
se<caret>t(value) {
doSmth(value)
set(value) {
<expr>doSmth</expr>(value)
}
fun doSmth(i: String): Unit = 4
@@ -1,4 +1,4 @@
var x: Int = 1
se<caret>t(value) = doSmth(value)
set(value) = <expr>doSmth</expr>(value)
fun doSmth(i: String): Unit = 4
@@ -1,4 +1,4 @@
var : Int = 1
se<caret>t(value) = doSmth(value)
set(value) = <expr>doSmth</expr>(value)
fun doSmth(i: String): Unit = 4
@@ -1,7 +1,7 @@
val x
get() = 1
se<caret>t(value) {
doSmth(value)
set(value) {
<expr>doSmth</expr>(value)
}
fun doSmth(i: String) = 4
@@ -1,5 +1,5 @@
val x
get() = 1
se<caret>t(value) = doSmth(value)
set(value) = <expr>doSmth</expr>(value)
fun doSmth(i: String) = 4