[FIR] SupertypeComputationSession: fix false positive invisible reference for local object

The problem is that FirAnonymousObject was ignored during getResolvedSuperTypeRefsForOutOfSessionDeclaration from SupertypeSupplier

^KT-58583 Fixed
This commit is contained in:
Dmitrii Gridin
2023-05-09 16:49:09 +02:00
committed by Space Team
parent c6d9821ef0
commit 2c294cba64
7 changed files with 50 additions and 2 deletions
@@ -597,6 +597,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/kt57214.kt");
}
@Test
@TestMetadata("kt58583.kt")
public void testKt58583() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt58583.kt");
}
@Test
@TestMetadata("LValueAssignment.kt")
public void testLValueAssignment() throws Exception {
@@ -597,6 +597,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/kt57214.kt");
}
@Test
@TestMetadata("kt58583.kt")
public void testKt58583() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt58583.kt");
}
@Test
@TestMetadata("LValueAssignment.kt")
public void testLValueAssignment() throws Exception {
@@ -597,6 +597,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/kt57214.kt");
}
@Test
@TestMetadata("kt58583.kt")
public void testKt58583() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt58583.kt");
}
@Test
@TestMetadata("LValueAssignment.kt")
public void testLValueAssignment() throws Exception {
@@ -597,6 +597,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/kt57214.kt");
}
@Test
@TestMetadata("kt58583.kt")
public void testKt58583() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt58583.kt");
}
@Test
@TestMetadata("LValueAssignment.kt")
public void testLValueAssignment() throws Exception {
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.utils.expandedConeType
import org.jetbrains.kotlin.fir.declarations.utils.isCompanion
import org.jetbrains.kotlin.fir.declarations.utils.superConeTypes
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
import org.jetbrains.kotlin.fir.expressions.FirStatement
@@ -624,7 +623,7 @@ open class SupertypeComputationSession {
protected open fun getResolvedSuperTypeRefsForOutOfSessionDeclaration(
classLikeDeclaration: FirClassLikeDeclaration,
): List<FirResolvedTypeRef>? = when (classLikeDeclaration) {
is FirRegularClass -> classLikeDeclaration.superTypeRefs.filterIsInstance<FirResolvedTypeRef>()
is FirClass -> classLikeDeclaration.superTypeRefs.filterIsInstance<FirResolvedTypeRef>()
is FirTypeAlias -> listOfNotNull(classLikeDeclaration.expandedTypeRef as? FirResolvedTypeRef)
else -> null
}
+19
View File
@@ -0,0 +1,19 @@
// FIR_IDENTICAL
// FILE: DialogWrapper.kt
package pkg
open class DialogWrapper {
protected open class DialogWrapperAction
}
// FILE: Main.kt
import pkg.DialogWrapper
fun main() {
object: DialogWrapper() {
init {
object: DialogWrapperAction() {}
}
}
}
@@ -597,6 +597,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/kt57214.kt");
}
@Test
@TestMetadata("kt58583.kt")
public void testKt58583() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt58583.kt");
}
@Test
@TestMetadata("LValueAssignment.kt")
public void testLValueAssignment() throws Exception {