[FIR] Remove a hack about local classes

^KT-54390 Fixed
This commit is contained in:
Nikolay Lunyak
2023-08-17 17:44:54 +03:00
committed by Space Team
parent f9c6af4d2a
commit 2c16c9a35b
8 changed files with 105 additions and 8 deletions
@@ -106,14 +106,6 @@ internal tailrec fun FirDeclaration.ktSymbolOrigin(): KtSymbolOrigin = when (ori
internal fun KtClassLikeSymbol.getSymbolKind(): KtSymbolKind {
val firSymbol = firSymbol
if (firSymbol.isLocal) {
// TODO: hack should be dropped after KT-54390
when {
firSymbol is FirRegularClassSymbol && firSymbol.fir.containingClassForLocalAttr == null -> {
return KtSymbolKind.LOCAL
}
}
}
return when {
firSymbol.classId.isNestedClass -> KtSymbolKind.CLASS_MEMBER
firSymbol.isLocal -> KtSymbolKind.LOCAL
@@ -524,6 +524,12 @@ public class DiagnosticCompilerTestFirTestdataTestGenerated extends AbstractDiag
runTest("compiler/fir/analysis-tests/testData/resolve/problems2.kt");
}
@Test
@TestMetadata("properLocalPackages.kt")
public void testProperLocalPackages() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/properLocalPackages.kt");
}
@Test
@TestMetadata("propertyFromJavaPlusAssign.kt")
public void testPropertyFromJavaPlusAssign() throws Exception {
@@ -524,6 +524,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated
runTest("compiler/fir/analysis-tests/testData/resolve/problems2.kt");
}
@Test
@TestMetadata("properLocalPackages.kt")
public void testProperLocalPackages() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/properLocalPackages.kt");
}
@Test
@TestMetadata("propertyFromJavaPlusAssign.kt")
public void testPropertyFromJavaPlusAssign() throws Exception {
@@ -444,6 +444,11 @@ public class LazyBodyIsNotTouchedTestGenerated extends AbstractLazyBodyIsNotTouc
runTest("compiler/fir/analysis-tests/testData/resolve/problems2.kt");
}
@TestMetadata("properLocalPackages.kt")
public void testProperLocalPackages() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/properLocalPackages.kt");
}
@TestMetadata("propertyFromJavaPlusAssign.kt")
public void testPropertyFromJavaPlusAssign() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/propertyFromJavaPlusAssign.kt");
@@ -0,0 +1,57 @@
FILE: properLocalPackages.kt
package a.b
public final class X : R|kotlin/Any| {
public constructor(): R|a/b/X| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Unit| {
local final class U : R|kotlin/Any| {
public constructor(): R|<local>/U| {
super<R|kotlin/Any|>()
}
local final inner class K : R|kotlin/Any| {
public <local>/U.constructor(): R|<local>/U.K| {
super<R|kotlin/Any|>()
}
local final inner class D : R|kotlin/Any| {
public <local>/U.K.constructor(): R|<local>/U.K.D| {
super<R|kotlin/Any|>()
}
public final fun check(): R|kotlin/Unit| {
local final class F : R|kotlin/Any| {
public constructor(): R|<local>/F| {
super<R|kotlin/Any|>()
}
local final inner class L : R|kotlin/Any| {
public <local>/F.constructor(): R|<local>/F.L| {
super<R|kotlin/Any|>()
}
}
}
}
}
}
local final class T : R|kotlin/Any| {
public constructor(): R|<local>/U.T| {
super<R|kotlin/Any|>()
}
}
}
}
}
@@ -0,0 +1,19 @@
package a.b
class X {
fun foo() {
class U {
inner class K {
inner class D {
fun check() {
class F {
inner class L
}
}
}
}
<!NESTED_CLASS_NOT_ALLOWED!>class T<!>
}
}
}
@@ -524,6 +524,12 @@ public class FirLightTreeDiagnosticsTestGenerated extends AbstractFirLightTreeDi
runTest("compiler/fir/analysis-tests/testData/resolve/problems2.kt");
}
@Test
@TestMetadata("properLocalPackages.kt")
public void testProperLocalPackages() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/properLocalPackages.kt");
}
@Test
@TestMetadata("propertyFromJavaPlusAssign.kt")
public void testPropertyFromJavaPlusAssign() throws Exception {
@@ -524,6 +524,12 @@ public class FirPsiDiagnosticTestGenerated extends AbstractFirPsiDiagnosticTest
runTest("compiler/fir/analysis-tests/testData/resolve/problems2.kt");
}
@Test
@TestMetadata("properLocalPackages.kt")
public void testProperLocalPackages() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/properLocalPackages.kt");
}
@Test
@TestMetadata("propertyFromJavaPlusAssign.kt")
public void testPropertyFromJavaPlusAssign() throws Exception {