Fix reference resolver bug for companion object whose name is the same as class

FirReferenceResolveHelper internally checks whether the referenced class
id matches the qualifed access or not. If they do not match, it reports
an error. When the companion object has the same name as the class,
resolving a qualified expression access to a member of the companion
object causes an error because of the mismatch e.g.,

```
package my.sample

class Test {
    fun a() {
        my.sample.<caret>Test.say()
    }

    companion object Test {
        fun say() {}
    }
}
```

This commit fixes the issue.

TODO: When the companion object has a name difference from class, it
does not report an error but the resolution result is wrong in FIR. See
KT-56167.

---

Commentary from rebaser: the issue mentioned in this code is
fixed in 71a368e06e, so the actual
fix is omitted, and only test data is preserved
This commit is contained in:
Jaebaek Seo
2023-01-25 01:34:46 +01:00
committed by teamcity
parent 633d182846
commit 860dee2cb1
10 changed files with 90 additions and 4 deletions
@@ -0,0 +1,11 @@
package my.sample
class Inner {
fun a() {
my.sample.<caret>Inner.say()
}
companion object Inner {
fun say() {}
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in my.sample.Inner) companion object Inner
@@ -0,0 +1,11 @@
package my.sample
class Inner {
fun a() {
my.<caret>sample.Inner.say()
}
companion object Inner {
fun say() {}
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: package my.sample