[FIR] Add the privateInFileInDifferentModule test

We only see the redeclaration
diagnostics on the declarations inside
the second file, because of
`FirRecorder::visitRegularClass`.
`data.state.classifierContainerFileMap`
references the last file, so
when checking the visibility of
the first `private class C { ... }`
(when collecting declarations that
conflict with the second `private class C`)
the provider returns the second file
instead of the first one, so the class
behaves as it is visible, and
`collectTopLevelConflict` returns in
this case.

As for why `INVISIBLE_*`s are reported
inside the first file: this is because
`data.state.classifierMap` stores the
last classifier it sees instead of
the first one.

^KT-62537
This commit is contained in:
Nikolay Lunyak
2023-10-04 16:10:50 +03:00
committed by Space Team
parent ba37ad9b85
commit a9ceae9667
7 changed files with 80 additions and 0 deletions
@@ -35214,6 +35214,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/typealias/privateInFile.kt");
}
@Test
@TestMetadata("privateInFileInDifferentModule.kt")
public void testPrivateInFileInDifferentModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/privateInFileInDifferentModule.kt");
}
@Test
@TestMetadata("projectionsInTypeAliasConstructor.kt")
public void testProjectionsInTypeAliasConstructor() throws Exception {
@@ -35328,6 +35328,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/typealias/privateInFile.kt");
}
@Test
@TestMetadata("privateInFileInDifferentModule.kt")
public void testPrivateInFileInDifferentModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/privateInFileInDifferentModule.kt");
}
@Test
@TestMetadata("projectionsInTypeAliasConstructor.kt")
public void testProjectionsInTypeAliasConstructor() throws Exception {
@@ -0,0 +1,25 @@
// ISSUE: KT-62537
// MODULE: m1
// FILE: file1.kt
private class C {
companion object
}
private typealias TA = C
private val test1: C = C()
private val test1co: C.Companion = C
private val test2: TA = TA()
private val test2co = TA
// MODULE: m2(m1)
// FILE: file2.kt
private val test1: C = C()
private val test1co: C.Companion = <!INITIALIZER_TYPE_MISMATCH, NO_COMPANION_OBJECT!>C<!>
private val test2: TA = <!INVISIBLE_REFERENCE!>TA<!>()
private val test2co = TA
private class C
private typealias TA = Int
@@ -0,0 +1,25 @@
// ISSUE: KT-62537
// MODULE: m1
// FILE: file1.kt
private class C {
companion object
}
private typealias TA = C
private val test1: C = C()
private val test1co: C.Companion = C
private val test2: TA = TA()
private val test2co = TA
// MODULE: m2(m1)
// FILE: file2.kt
private val test1: C = C()
private val test1co: C.<!UNRESOLVED_REFERENCE!>Companion<!> = <!NO_COMPANION_OBJECT!>C<!>
private val test2: TA = <!INVISIBLE_MEMBER!>TA<!>()
private val test2co = TA
private class C
private typealias TA = Int
@@ -37202,6 +37202,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/typealias/privateInFile.kt");
}
@Test
@TestMetadata("privateInFileInDifferentModule.kt")
public void testPrivateInFileInDifferentModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/privateInFileInDifferentModule.kt");
}
@Test
@TestMetadata("projectionsInTypeAliasConstructor.kt")
public void testProjectionsInTypeAliasConstructor() throws Exception {