KT-66411 [AA] Add test for the getOrBuildFir on array assignment expression as a single when/if branch expression

This commit is contained in:
Roman Golyshev
2024-03-07 22:40:58 +01:00
committed by Space Team
parent 83a80a45a9
commit ec06654a73
6 changed files with 110 additions and 0 deletions
@@ -0,0 +1,10 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtBinaryExpression
class Foo {
operator fun set(n: Int, value: String) {}
}
fun usageFoo(flag: Boolean, foo: Foo) {
if (flag) <expr>foo[10] = ""</expr>
}
@@ -0,0 +1,33 @@
KT element: KtBinaryExpression
FIR element: FirBlockImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
{
R|<local>/foo|.R|/Foo.set|(Int(10), String())
Unit
}
FIR FILE:
FILE: [ResolvedTo(IMPORTS)] arrayAssignOperatorAsSingleExpressionInIf.kt
public final [ResolvedTo(STATUS)] class Foo : R|kotlin/Any| {
public [ResolvedTo(STATUS)] [ContainingClassKey=Foo] constructor(): R|Foo| {
LAZY_super<R|kotlin/Any|>
}
public final operator [ResolvedTo(CONTRACTS)] fun set([ResolvedTo(CONTRACTS)] n: R|kotlin/Int|, [ResolvedTo(CONTRACTS)] value: R|kotlin/String|): R|kotlin/Unit| {
}
}
public final [ResolvedTo(BODY_RESOLVE)] fun usageFoo([ResolvedTo(BODY_RESOLVE)] flag: R|kotlin/Boolean|, [ResolvedTo(BODY_RESOLVE)] foo: R|Foo|): R|kotlin/Unit| {
when () {
R|<local>/flag| -> {
{
R|<local>/foo|.R|/Foo.set|(Int(10), String())
Unit
}
}
}
}
@@ -0,0 +1,10 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtBinaryExpression
class Foo {
operator fun set(n: Int, value: String) {}
}
fun usageFoo(foo: Foo) {
when { else -> <expr>foo[10] = ""</expr> }
}
@@ -0,0 +1,33 @@
KT element: KtBinaryExpression
FIR element: FirBlockImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
{
R|<local>/foo|.R|/Foo.set|(Int(10), String())
Unit
}
FIR FILE:
FILE: [ResolvedTo(IMPORTS)] arrayAssignOperatorAsSingleExpressionInWhen.kt
public final [ResolvedTo(STATUS)] class Foo : R|kotlin/Any| {
public [ResolvedTo(STATUS)] [ContainingClassKey=Foo] constructor(): R|Foo| {
LAZY_super<R|kotlin/Any|>
}
public final operator [ResolvedTo(CONTRACTS)] fun set([ResolvedTo(CONTRACTS)] n: R|kotlin/Int|, [ResolvedTo(CONTRACTS)] value: R|kotlin/String|): R|kotlin/Unit| {
}
}
public final [ResolvedTo(BODY_RESOLVE)] fun usageFoo([ResolvedTo(BODY_RESOLVE)] foo: R|Foo|): R|kotlin/Unit| {
when () {
else -> {
{
R|<local>/foo|.R|/Foo.set|(Int(10), String())
Unit
}
}
}
}