KT-60954 [Analysis API] Unwrap variable assignments in KtFirReferenceShortener

To get to the proper qualified expression, we need to unwrap the outer
`FirVariableAssignment` if we deal with the property access inside of
assignment expressions

^KT-60954 Fixed
This commit is contained in:
Roman Golyshev
2023-08-04 15:37:03 +02:00
committed by teamcity
parent 7151e6a41c
commit ab8726cff1
9 changed files with 108 additions and 1 deletions
@@ -0,0 +1,11 @@
// FILE: main.kt
package test
fun usage() {
<expr>dependency.foo = 20</expr>
}
// FILE: dependency.kt
package dependency
var foo: Int = 10
@@ -0,0 +1,7 @@
Before shortening: dependency.foo = 20
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[qualifier] dependency.foo
with SHORTEN_AND_STAR_IMPORT:
[qualifier] dependency.foo
@@ -0,0 +1,15 @@
// FILE: main.kt
package test
fun usage() {
<expr>dependency.foo += 20</expr>
}
// FILE: dependency.kt
package dependency
val foo: Foo = Foo()
class Foo {
operator fun plusAssign(i: Int) {}
}
@@ -0,0 +1,7 @@
Before shortening: dependency.foo += 20
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[qualifier] dependency.foo
with SHORTEN_AND_STAR_IMPORT:
[qualifier] dependency.foo
@@ -0,0 +1,15 @@
// FILE: main.kt
package test
fun usage() {
<expr>dependency.foo += 20</expr>
}
// FILE: dependency.kt
package dependency
var foo: Foo = Foo()
class Foo {
operator fun plus(i: Int): Foo = this
}
@@ -0,0 +1,7 @@
Before shortening: dependency.foo += 20
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[qualifier] dependency.foo
with SHORTEN_AND_STAR_IMPORT:
[qualifier] dependency.foo