[FIR] Include anonymous objects in containingDeclarations in FirDeclarationsResolveTransformer.kt
K1 and K2 still differ because of KT-58203 #KT-63434
This commit is contained in:
committed by
Space Team
parent
eb23984182
commit
55adeba011
+6
@@ -40552,6 +40552,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/visibility/kt56283.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63434.kt")
|
||||
public void testKt63434() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/visibility/kt63434.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lackOfInvisibleSetterOfJavaClassInSamePackage.kt")
|
||||
public void testLackOfInvisibleSetterOfJavaClassInSamePackage() throws Exception {
|
||||
|
||||
+6
@@ -40552,6 +40552,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/visibility/kt56283.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63434.kt")
|
||||
public void testKt63434() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/visibility/kt63434.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lackOfInvisibleSetterOfJavaClassInSamePackage.kt")
|
||||
public void testLackOfInvisibleSetterOfJavaClassInSamePackage() throws Exception {
|
||||
|
||||
+6
@@ -38220,6 +38220,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/visibility/kt56283.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63434.kt")
|
||||
public void testKt63434() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/visibility/kt63434.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lackOfInvisibleSetterOfJavaClassInSamePackage.kt")
|
||||
public void testLackOfInvisibleSetterOfJavaClassInSamePackage() throws Exception {
|
||||
|
||||
+6
@@ -38346,6 +38346,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/visibility/kt56283.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63434.kt")
|
||||
public void testKt63434() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/visibility/kt63434.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lackOfInvisibleSetterOfJavaClassInSamePackage.kt")
|
||||
public void testLackOfInvisibleSetterOfJavaClassInSamePackage() throws Exception {
|
||||
|
||||
+9
-9
@@ -79,7 +79,7 @@ class BodyResolveContext(
|
||||
val whenSubjectImportingScopes: ArrayDeque<FirWhenSubjectImportingScope?> = ArrayDeque()
|
||||
|
||||
@set:PrivateForInline
|
||||
var containingClass: FirRegularClass? = null
|
||||
var containingRegularClass: FirRegularClass? = null
|
||||
|
||||
val containerIfAny: FirDeclaration?
|
||||
get() = containers.lastOrNull()
|
||||
@@ -107,7 +107,7 @@ class BodyResolveContext(
|
||||
|
||||
val anonymousFunctionsAnalyzedInDependentContext: MutableSet<FirFunctionSymbol<*>> = mutableSetOf()
|
||||
|
||||
var containingClassDeclarations: ArrayDeque<FirRegularClass> = ArrayDeque()
|
||||
var containingClassDeclarations: ArrayDeque<FirClass> = ArrayDeque()
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
inline fun <T> withTowerDataContexts(newContexts: FirRegularTowerDataContexts, f: () -> T): T {
|
||||
@@ -140,19 +140,19 @@ class BodyResolveContext(
|
||||
}
|
||||
|
||||
@PrivateForInline
|
||||
private inline fun <T> withContainerClass(declaration: FirRegularClass, f: () -> T): T {
|
||||
val oldContainingClass = containingClass
|
||||
private inline fun <T> withContainerRegularClass(declaration: FirRegularClass, f: () -> T): T {
|
||||
val oldContainingClass = containingRegularClass
|
||||
containers.add(declaration)
|
||||
containingClass = declaration
|
||||
containingRegularClass = declaration
|
||||
return try {
|
||||
f()
|
||||
} finally {
|
||||
containers.removeLast()
|
||||
containingClass = oldContainingClass
|
||||
containingRegularClass = oldContainingClass
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T> withContainingClass(declaration: FirRegularClass, f: () -> T): T {
|
||||
inline fun <T> withContainingClass(declaration: FirClass, f: () -> T): T {
|
||||
containingClassDeclarations.add(declaration)
|
||||
return try {
|
||||
f()
|
||||
@@ -368,7 +368,7 @@ class BodyResolveContext(
|
||||
specialTowerDataContexts.putAll(this@BodyResolveContext.specialTowerDataContexts)
|
||||
containers = this@BodyResolveContext.containers
|
||||
containingClassDeclarations = ArrayDeque(this@BodyResolveContext.containingClassDeclarations)
|
||||
containingClass = this@BodyResolveContext.containingClass
|
||||
containingRegularClass = this@BodyResolveContext.containingRegularClass
|
||||
replaceTowerDataContext(this@BodyResolveContext.towerDataContext)
|
||||
anonymousFunctionsAnalyzedInDependentContext.addAll(this@BodyResolveContext.anonymousFunctionsAnalyzedInDependentContext)
|
||||
// Looks like we should copy this session only for builder inference to be able
|
||||
@@ -417,7 +417,7 @@ class BodyResolveContext(
|
||||
}
|
||||
|
||||
withScopesForClass(regularClass, holder) {
|
||||
withContainerClass(regularClass, f)
|
||||
withContainerRegularClass(regularClass, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-14
@@ -292,7 +292,7 @@ open class FirDeclarationsResolveTransformer(
|
||||
if (property.returnTypeRef is FirResolvedTypeRef) {
|
||||
val typeArguments = (type.type as ConeClassLikeType).typeArguments
|
||||
val extensionType = property.receiverParameter?.typeRef?.coneType
|
||||
val dispatchType = context.containingClass?.let { containingClass ->
|
||||
val dispatchType = context.containingRegularClass?.let { containingClass ->
|
||||
containingClass.symbol.constructStarProjectedType(containingClass.typeParameters.size)
|
||||
}
|
||||
propertyReferenceAccess.replaceConeTypeOrNull(
|
||||
@@ -789,21 +789,23 @@ open class FirDeclarationsResolveTransformer(
|
||||
anonymousObject: FirAnonymousObject,
|
||||
data: ResolutionMode
|
||||
): FirAnonymousObject = whileAnalysing(session, anonymousObject) {
|
||||
if (anonymousObject !in context.targetedLocalClasses) {
|
||||
return anonymousObject.runAllPhasesForLocalClass(components, data, transformer.firResolveContextCollector)
|
||||
}
|
||||
context.withContainingClass(anonymousObject) {
|
||||
if (anonymousObject !in context.targetedLocalClasses) {
|
||||
return anonymousObject.runAllPhasesForLocalClass(components, data, transformer.firResolveContextCollector)
|
||||
}
|
||||
|
||||
require(anonymousObject.controlFlowGraphReference == null)
|
||||
val buildGraph = !implicitTypeOnly
|
||||
dataFlowAnalyzer.enterClass(anonymousObject, buildGraph)
|
||||
val result = context.withAnonymousObject(anonymousObject, components) {
|
||||
transformDeclarationContent(anonymousObject, data) as FirAnonymousObject
|
||||
require(anonymousObject.controlFlowGraphReference == null)
|
||||
val buildGraph = !implicitTypeOnly
|
||||
dataFlowAnalyzer.enterClass(anonymousObject, buildGraph)
|
||||
val result = context.withAnonymousObject(anonymousObject, components) {
|
||||
transformDeclarationContent(anonymousObject, data) as FirAnonymousObject
|
||||
}
|
||||
val graph = dataFlowAnalyzer.exitClass()
|
||||
if (graph != null) {
|
||||
result.replaceControlFlowGraphReference(FirControlFlowGraphReferenceImpl(graph))
|
||||
}
|
||||
result
|
||||
}
|
||||
val graph = dataFlowAnalyzer.exitClass()
|
||||
if (graph != null) {
|
||||
result.replaceControlFlowGraphReference(FirControlFlowGraphReferenceImpl(graph))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun transformSimpleFunction(
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// SKIP_TXT
|
||||
// FIR_DUMP
|
||||
|
||||
abstract class InlineCompletionSessionManager {
|
||||
protected class Proto {
|
||||
class Some
|
||||
}
|
||||
}
|
||||
|
||||
fun checkCannotAccess() {
|
||||
object : InlineCompletionSessionManager() {
|
||||
fun chch() {
|
||||
val b: Proto = Proto()
|
||||
if (b is Proto.Some) return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
FILE: kt63434.fir.kt
|
||||
public abstract class InlineCompletionSessionManager : R|kotlin/Any| {
|
||||
public constructor(): R|InlineCompletionSessionManager| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
protected final class Proto : R|kotlin/Any| {
|
||||
public constructor(): R|InlineCompletionSessionManager.Proto| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final class Some : R|kotlin/Any| {
|
||||
public constructor(): R|InlineCompletionSessionManager.Proto.Some| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final fun checkCannotAccess(): R|kotlin/Unit| {
|
||||
object : R|InlineCompletionSessionManager| {
|
||||
private constructor(): R|<anonymous>| {
|
||||
super<R|InlineCompletionSessionManager|>()
|
||||
}
|
||||
|
||||
public final fun chch(): R|kotlin/Unit| {
|
||||
lval b: R|InlineCompletionSessionManager.Proto| = R|/InlineCompletionSessionManager.Proto.Proto|()
|
||||
when () {
|
||||
(R|<local>/b| is R|InlineCompletionSessionManager.Proto.Some|) -> {
|
||||
^chch Unit
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// SKIP_TXT
|
||||
// FIR_DUMP
|
||||
|
||||
abstract class InlineCompletionSessionManager {
|
||||
protected class Proto {
|
||||
class Some
|
||||
}
|
||||
}
|
||||
|
||||
fun checkCannotAccess() {
|
||||
object : InlineCompletionSessionManager() {
|
||||
fun chch() {
|
||||
val b: Proto = Proto()
|
||||
if (b is <!INCOMPATIBLE_TYPES!>Proto.Some<!>) return
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+6
@@ -40552,6 +40552,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/visibility/kt56283.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63434.kt")
|
||||
public void testKt63434() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/visibility/kt63434.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lackOfInvisibleSetterOfJavaClassInSamePackage.kt")
|
||||
public void testLackOfInvisibleSetterOfJavaClassInSamePackage() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user