[FIR] Pass proper containing classes from context to type resolution for local classes
This commit is contained in:
committed by
teamcityserver
parent
98934e15c0
commit
2b84e8e68f
+6
@@ -32281,6 +32281,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
|
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("privateFromInAnonymousObject.kt")
|
||||||
|
public void testPrivateFromInAnonymousObject() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/visibility/privateFromInAnonymousObject.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("protectedInternal.kt")
|
@TestMetadata("protectedInternal.kt")
|
||||||
public void testProtectedInternal() throws Exception {
|
public void testProtectedInternal() throws Exception {
|
||||||
|
|||||||
+6
@@ -32281,6 +32281,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
|
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("privateFromInAnonymousObject.kt")
|
||||||
|
public void testPrivateFromInAnonymousObject() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/visibility/privateFromInAnonymousObject.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("protectedInternal.kt")
|
@TestMetadata("protectedInternal.kt")
|
||||||
public void testProtectedInternal() throws Exception {
|
public void testProtectedInternal() throws Exception {
|
||||||
|
|||||||
+6
@@ -32281,6 +32281,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
|
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("privateFromInAnonymousObject.kt")
|
||||||
|
public void testPrivateFromInAnonymousObject() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/visibility/privateFromInAnonymousObject.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("protectedInternal.kt")
|
@TestMetadata("protectedInternal.kt")
|
||||||
public void testProtectedInternal() throws Exception {
|
public void testProtectedInternal() throws Exception {
|
||||||
|
|||||||
+14
-4
@@ -33,8 +33,17 @@ fun <F : FirClassLikeDeclaration> F.runTypeResolvePhaseForLocalClass(
|
|||||||
session: FirSession,
|
session: FirSession,
|
||||||
scopeSession: ScopeSession,
|
scopeSession: ScopeSession,
|
||||||
currentScopeList: List<FirScope>,
|
currentScopeList: List<FirScope>,
|
||||||
|
useSiteFile: FirFile,
|
||||||
|
containingDeclarations: List<FirDeclaration>,
|
||||||
): F {
|
): F {
|
||||||
val transformer = FirTypeResolveTransformer(session, scopeSession, currentScopeList)
|
@Suppress("RemoveExplicitTypeArguments")
|
||||||
|
val transformer = FirTypeResolveTransformer(
|
||||||
|
session,
|
||||||
|
scopeSession,
|
||||||
|
currentScopeList,
|
||||||
|
initialCurrentFile = useSiteFile,
|
||||||
|
classDeclarationsStack = containingDeclarations.filterIsInstanceTo<FirClass, ArrayDeque<FirClass>>(ArrayDeque())
|
||||||
|
)
|
||||||
|
|
||||||
return this.transform<F, Nothing?>(transformer, null)
|
return this.transform<F, Nothing?>(transformer, null)
|
||||||
}
|
}
|
||||||
@@ -42,9 +51,10 @@ fun <F : FirClassLikeDeclaration> F.runTypeResolvePhaseForLocalClass(
|
|||||||
open class FirTypeResolveTransformer(
|
open class FirTypeResolveTransformer(
|
||||||
final override val session: FirSession,
|
final override val session: FirSession,
|
||||||
private val scopeSession: ScopeSession,
|
private val scopeSession: ScopeSession,
|
||||||
initialScopes: List<FirScope> = emptyList()
|
initialScopes: List<FirScope> = emptyList(),
|
||||||
|
initialCurrentFile: FirFile? = null,
|
||||||
|
private val classDeclarationsStack: ArrayDeque<FirClass> = ArrayDeque()
|
||||||
) : FirAbstractTreeTransformer<Any?>(FirResolvePhase.TYPES) {
|
) : FirAbstractTreeTransformer<Any?>(FirResolvePhase.TYPES) {
|
||||||
private val classDeclarationsStack = ArrayDeque<FirClass>()
|
|
||||||
private val scopes = mutableListOf<FirScope>()
|
private val scopes = mutableListOf<FirScope>()
|
||||||
private val towerScope = scopes.asReversed()
|
private val towerScope = scopes.asReversed()
|
||||||
|
|
||||||
@@ -53,7 +63,7 @@ open class FirTypeResolveTransformer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val typeResolverTransformer: FirSpecificTypeResolverTransformer = FirSpecificTypeResolverTransformer(session)
|
private val typeResolverTransformer: FirSpecificTypeResolverTransformer = FirSpecificTypeResolverTransformer(session)
|
||||||
private var currentFile: FirFile? = null
|
private var currentFile: FirFile? = initialCurrentFile
|
||||||
|
|
||||||
override fun transformFile(file: FirFile, data: Any?): FirFile {
|
override fun transformFile(file: FirFile, data: Any?): FirFile {
|
||||||
checkSessionConsistency(file)
|
checkSessionConsistency(file)
|
||||||
|
|||||||
+2
@@ -338,6 +338,8 @@ class BodyResolveContext(
|
|||||||
towerDataContextForAnonymousFunctions.putAll(this@BodyResolveContext.towerDataContextForAnonymousFunctions)
|
towerDataContextForAnonymousFunctions.putAll(this@BodyResolveContext.towerDataContextForAnonymousFunctions)
|
||||||
towerDataContextForCallableReferences.putAll(this@BodyResolveContext.towerDataContextForCallableReferences)
|
towerDataContextForCallableReferences.putAll(this@BodyResolveContext.towerDataContextForCallableReferences)
|
||||||
containers = this@BodyResolveContext.containers
|
containers = this@BodyResolveContext.containers
|
||||||
|
containingClassDeclarations = ArrayDeque(this@BodyResolveContext.containingClassDeclarations)
|
||||||
|
containingClass = this@BodyResolveContext.containingClass
|
||||||
replaceTowerDataContext(this@BodyResolveContext.towerDataContext)
|
replaceTowerDataContext(this@BodyResolveContext.towerDataContext)
|
||||||
anonymousFunctionsAnalyzedInDependentContext.addAll(this@BodyResolveContext.anonymousFunctionsAnalyzedInDependentContext)
|
anonymousFunctionsAnalyzedInDependentContext.addAll(this@BodyResolveContext.anonymousFunctionsAnalyzedInDependentContext)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -44,7 +44,9 @@ fun <F : FirClassLikeDeclaration> F.runAllPhasesForLocalClass(
|
|||||||
runTypeResolvePhaseForLocalClass(
|
runTypeResolvePhaseForLocalClass(
|
||||||
components.session,
|
components.session,
|
||||||
components.scopeSession,
|
components.scopeSession,
|
||||||
components.createCurrentScopeList()
|
components.createCurrentScopeList(),
|
||||||
|
components.file,
|
||||||
|
components.containingDeclarations
|
||||||
)
|
)
|
||||||
runStatusResolveForLocalClass(
|
runStatusResolveForLocalClass(
|
||||||
components.session,
|
components.session,
|
||||||
|
|||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
FILE: privateFromInAnonymousObject.kt
|
||||||
|
public final class Base : R|kotlin/Any| {
|
||||||
|
public constructor(): R|Base| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class Private : R|kotlin/Any| {
|
||||||
|
public constructor(): R|Base.Private| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public final fun test(): R|kotlin/Unit| {
|
||||||
|
object : R|kotlin/Any| {
|
||||||
|
private constructor(): R|<anonymous>| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final val x: R|Base.Private| = R|/Base.Private.Private|()
|
||||||
|
public get(): R|Base.Private|
|
||||||
|
|
||||||
|
init {
|
||||||
|
lval y: R|Base.Private| = R|/Base.Private.Private|()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final fun foo(): R|kotlin/Unit| {
|
||||||
|
lval z: R|Base.Private| = R|/Base.Private.Private|()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// FIR_DUMP
|
||||||
|
|
||||||
|
class Base {
|
||||||
|
private class Private
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
object {
|
||||||
|
val x: Private = Private()
|
||||||
|
|
||||||
|
init {
|
||||||
|
val y: Private = Private()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
val z: Private = Private()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public final class Base {
|
||||||
|
public constructor Base()
|
||||||
|
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 final fun test(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
private final class Private {
|
||||||
|
public constructor Private()
|
||||||
|
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
+6
@@ -32377,6 +32377,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
|
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("privateFromInAnonymousObject.kt")
|
||||||
|
public void testPrivateFromInAnonymousObject() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/visibility/privateFromInAnonymousObject.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("protectedInternal.kt")
|
@TestMetadata("protectedInternal.kt")
|
||||||
public void testProtectedInternal() throws Exception {
|
public void testProtectedInternal() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user