[FIR] Consider anonymous object declarations in classDeclarationsStack in transformers
This commit is contained in:
committed by
TeamCityServer
parent
b83ed7a6ed
commit
3beb447e85
+9
-3
@@ -11243,6 +11243,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/generics"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("anonymousObjectSupertypeWithTypeParameterFromFunction.kt")
|
||||
public void testAnonymousObjectSupertypeWithTypeParameterFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/anonymousObjectSupertypeWithTypeParameterFromFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("argumentsForT.kt")
|
||||
public void testArgumentsForT() throws Exception {
|
||||
@@ -11352,9 +11358,9 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localClassWithTypeArgumentFromFunction.kt")
|
||||
public void testLocalClassWithTypeArgumentFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/localClassWithTypeArgumentFromFunction.kt");
|
||||
@TestMetadata("localClassTypeRefWithTypeParameterFromFunction.kt")
|
||||
public void testLocalClassTypeRefWithTypeParameterFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+9
-3
@@ -11243,6 +11243,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/generics"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("anonymousObjectSupertypeWithTypeParameterFromFunction.kt")
|
||||
public void testAnonymousObjectSupertypeWithTypeParameterFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/anonymousObjectSupertypeWithTypeParameterFromFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("argumentsForT.kt")
|
||||
public void testArgumentsForT() throws Exception {
|
||||
@@ -11352,9 +11358,9 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localClassWithTypeArgumentFromFunction.kt")
|
||||
public void testLocalClassWithTypeArgumentFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/localClassWithTypeArgumentFromFunction.kt");
|
||||
@TestMetadata("localClassTypeRefWithTypeParameterFromFunction.kt")
|
||||
public void testLocalClassTypeRefWithTypeParameterFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+9
-3
@@ -11243,6 +11243,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/generics"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("anonymousObjectSupertypeWithTypeParameterFromFunction.kt")
|
||||
public void testAnonymousObjectSupertypeWithTypeParameterFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/anonymousObjectSupertypeWithTypeParameterFromFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("argumentsForT.kt")
|
||||
public void testArgumentsForT() throws Exception {
|
||||
@@ -11352,9 +11358,9 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localClassWithTypeArgumentFromFunction.kt")
|
||||
public void testLocalClassWithTypeArgumentFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/localClassWithTypeArgumentFromFunction.kt");
|
||||
@TestMetadata("localClassTypeRefWithTypeParameterFromFunction.kt")
|
||||
public void testLocalClassTypeRefWithTypeParameterFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+6
-4
@@ -215,11 +215,11 @@ open class FirSupertypeResolverVisitor(
|
||||
containingDeclarations: List<FirDeclaration> = emptyList(),
|
||||
) : FirDefaultVisitor<Unit, Any?>() {
|
||||
private val supertypeGenerationExtensions = session.extensionService.supertypeGenerators
|
||||
private val classDeclarationsStack = ArrayDeque<FirRegularClass>()
|
||||
private val classDeclarationsStack = ArrayDeque<FirClass>()
|
||||
|
||||
init {
|
||||
containingDeclarations.forEach {
|
||||
if (it is FirRegularClass) {
|
||||
if (it is FirClass) {
|
||||
classDeclarationsStack.add(it)
|
||||
}
|
||||
}
|
||||
@@ -368,8 +368,10 @@ open class FirSupertypeResolverVisitor(
|
||||
}
|
||||
|
||||
override fun visitAnonymousObject(anonymousObject: FirAnonymousObject, data: Any?) {
|
||||
resolveSpecificClassLikeSupertypes(anonymousObject, anonymousObject.superTypeRefs)
|
||||
visitDeclarationContent(anonymousObject, null)
|
||||
withClassDeclarationCleanup(classDeclarationsStack, anonymousObject) {
|
||||
resolveSpecificClassLikeSupertypes(anonymousObject, anonymousObject.superTypeRefs)
|
||||
visitDeclarationContent(anonymousObject, null)
|
||||
}
|
||||
}
|
||||
|
||||
fun resolveSpecificClassLikeSupertypes(
|
||||
|
||||
+4
-2
@@ -44,7 +44,7 @@ open class FirTypeResolveTransformer(
|
||||
private val scopeSession: ScopeSession,
|
||||
initialScopes: List<FirScope> = emptyList()
|
||||
) : FirAbstractTreeTransformer<Any?>(FirResolvePhase.TYPES) {
|
||||
private val classDeclarationsStack = ArrayDeque<FirRegularClass>()
|
||||
private val classDeclarationsStack = ArrayDeque<FirClass>()
|
||||
private val scopes = mutableListOf<FirScope>()
|
||||
private val towerScope = scopes.asReversed()
|
||||
|
||||
@@ -79,7 +79,9 @@ open class FirTypeResolveTransformer(
|
||||
}
|
||||
|
||||
override fun transformAnonymousObject(anonymousObject: FirAnonymousObject, data: Any?): FirStatement {
|
||||
return resolveClassContent(anonymousObject, data)
|
||||
withClassDeclarationCleanup(classDeclarationsStack, anonymousObject) {
|
||||
return resolveClassContent(anonymousObject, data)
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformConstructor(constructor: FirConstructor, data: Any?): FirConstructor {
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
import org.jetbrains.kotlin.KtFakeSourceElementKind
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.copyWithNewSourceKind
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypedDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
@@ -135,8 +135,8 @@ inline fun <T> withScopeCleanup(scopes: MutableList<*>, l: () -> T): T {
|
||||
}
|
||||
|
||||
inline fun <T> withClassDeclarationCleanup(
|
||||
classDeclarations: ArrayDeque<FirRegularClass>,
|
||||
topClassDeclaration: FirRegularClass,
|
||||
classDeclarations: ArrayDeque<FirClass>,
|
||||
topClassDeclaration: FirClass,
|
||||
l: () -> T
|
||||
): T {
|
||||
classDeclarations.addLast(topClassDeclaration)
|
||||
|
||||
+2
-5
@@ -12,10 +12,7 @@ import kotlinx.collections.immutable.persistentListOf
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
@@ -106,7 +103,7 @@ private class FirAnnotationResolveTransformer(
|
||||
)
|
||||
|
||||
private var owners: PersistentList<FirDeclaration> = persistentListOf()
|
||||
private val classDeclarationsStack = ArrayDeque<FirRegularClass>()
|
||||
private val classDeclarationsStack = ArrayDeque<FirClass>()
|
||||
|
||||
override fun beforeTransformingChildren(parentDeclaration: FirDeclaration): PersistentList<FirDeclaration> {
|
||||
val current = owners
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// FIR_IDENTICAL
|
||||
abstract class Checker<StateT>
|
||||
|
||||
class ToolchainPanel {
|
||||
fun <ItemT> addVersionChecker(item: ItemT) {
|
||||
class MyState(val selectedItem: ItemT?)
|
||||
object : Checker<MyState>() {}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package
|
||||
|
||||
public abstract class Checker</*0*/ StateT> {
|
||||
public constructor Checker</*0*/ StateT>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class ToolchainPanel {
|
||||
public constructor ToolchainPanel()
|
||||
public final fun </*0*/ ItemT> addVersionChecker(/*0*/ item: ItemT): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Generated
+9
-3
@@ -11249,6 +11249,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/generics"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("anonymousObjectSupertypeWithTypeParameterFromFunction.kt")
|
||||
public void testAnonymousObjectSupertypeWithTypeParameterFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/anonymousObjectSupertypeWithTypeParameterFromFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("argumentsForT.kt")
|
||||
public void testArgumentsForT() throws Exception {
|
||||
@@ -11358,9 +11364,9 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localClassWithTypeArgumentFromFunction.kt")
|
||||
public void testLocalClassWithTypeArgumentFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/localClassWithTypeArgumentFromFunction.kt");
|
||||
@TestMetadata("localClassTypeRefWithTypeParameterFromFunction.kt")
|
||||
public void testLocalClassTypeRefWithTypeParameterFromFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user