[FIR] Reuse expect/actual matching data of outer declarations during matching of inner declarations

Review: https://jetbrains.team/p/kt/reviews/13244

Motivation:
    ```
    // Module :lib
    class Foo {
        val member: Int = 2
    }

    // Module :app
    // dependencies { implementation(project(":lib")) }
    class Foo {
        val member: Int = 2
    }
    ```

    Before the commit:
        app_Foo.expectForActual is `null`
        app_Foo.member.expectForActual = lib_foo.member
    After the commit:
        app_Foo.expectForActual is `null`
        app_Foo.member.expectForActual is `null`

    If I don't fix this problem then
    `CommonizerHierarchicalIT.testCommonizeHierarchicallyMultiModule`
    becomes red after I fix KT-59887 in the following commits

    `app_Foo.member.expectForActual = lib_foo.member` happens because we
    also need to match fake-overrides (KT-63550)

I didn't measure it, but theoretically, this commit should be a
performance improvement, becuase we reuse `expectForActual` cache

Additionally, The commit breaks some other tests (e.g.
compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.fir.kt).
The tests will become green again, once I fix KT-59887
This commit is contained in:
Nikita Bobko
2023-11-30 19:04:55 +01:00
committed by Space Team
parent 453d871b25
commit e44e84d1b0
4 changed files with 18 additions and 7 deletions
@@ -46,7 +46,7 @@ actual class Bar5 {
}
class Bar6 {
actual constructor()
<!ACTUAL_WITHOUT_EXPECT!>actual constructor()<!>
}
actual class Bar7 actual constructor(s: String) {
@@ -9,5 +9,5 @@ expect class A {
// FILE: jvm.kt
class A {
actual fun foo() {}
actual fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
}