From f68c8f8f0108fb7ff46ecbbe3e6b3016b64a710e Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Wed, 1 Dec 2021 16:57:27 +0300 Subject: [PATCH] [FIR] Fix visibility issues with private members within inner and anonymous scopes ^KT-49992 Fixed --- ...CompilerTestFE10TestdataTestGenerated.java | 6 + ...irOldFrontendDiagnosticsTestGenerated.java | 6 + ...DiagnosticsWithLightTreeTestGenerated.java | 6 + .../fir/java/FirJavaVisibilityChecker.kt | 2 +- .../kotlin/fir/FirVisibilityChecker.kt | 99 +++++++++++++--- .../fir/resolve/calls/VisibilityUtils.kt | 39 ++++--- .../testData/codegen/box/objects/kt3684.kt | 3 - .../innerNestedAndAnonymousClasses.fir.kt | 76 +++++++++++++ .../innerNestedAndAnonymousClasses.kt | 76 +++++++++++++ .../innerNestedAndAnonymousClasses.txt | 106 ++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 + 11 files changed, 390 insertions(+), 35 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.fir.kt create mode 100644 compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.kt create mode 100644 compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.txt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 66c2422c54d..0d343bb9c98 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -32625,6 +32625,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("innerNestedAndAnonymousClasses.kt") + public void testInnerNestedAndAnonymousClasses() throws Exception { + runTest("compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.kt"); + } + @Test @TestMetadata("invisibleSetterOfJavaClass.kt") public void testInvisibleSetterOfJavaClass() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 4ad93d17a2d..bb96f0ae5c7 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -32625,6 +32625,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("innerNestedAndAnonymousClasses.kt") + public void testInnerNestedAndAnonymousClasses() throws Exception { + runTest("compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.kt"); + } + @Test @TestMetadata("invisibleSetterOfJavaClass.kt") public void testInvisibleSetterOfJavaClass() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index 97268c13819..33fbddd455c 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -32625,6 +32625,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("innerNestedAndAnonymousClasses.kt") + public void testInnerNestedAndAnonymousClasses() throws Exception { + runTest("compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.kt"); + } + @Test @TestMetadata("invisibleSetterOfJavaClass.kt") public void testInvisibleSetterOfJavaClass() throws Exception { diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaVisibilityChecker.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaVisibilityChecker.kt index de4aa493f3e..622a7408cc1 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaVisibilityChecker.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaVisibilityChecker.kt @@ -41,7 +41,7 @@ object FirJavaVisibilityChecker : FirVisibilityChecker() { val ownerLookupTag = symbol.getOwnerLookupTag() ?: return false if (canSeeProtectedMemberOf( containingDeclarations, dispatchReceiver, ownerLookupTag, session, - isVariableOrNamedFunction = symbol is FirVariableSymbol || symbol is FirNamedFunctionSymbol || symbol is FirPropertyAccessorSymbol, + isVariableOrNamedFunction = symbol.isVariableOrNamedFunction(), isSyntheticProperty = symbol.fir is FirSyntheticPropertyAccessor, supertypeSupplier ) diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/FirVisibilityChecker.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/FirVisibilityChecker.kt index 896dc209505..689e630acea 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/FirVisibilityChecker.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/FirVisibilityChecker.kt @@ -6,17 +6,17 @@ package org.jetbrains.kotlin.fir import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticPropertyAccessor import org.jetbrains.kotlin.fir.declarations.utils.* import org.jetbrains.kotlin.fir.expressions.FirPropertyAccessExpression +import org.jetbrains.kotlin.fir.expressions.FirThisReceiverExpression import org.jetbrains.kotlin.fir.references.FirSuperReference import org.jetbrains.kotlin.fir.resolve.* -import org.jetbrains.kotlin.fir.resolve.calls.ExpressionReceiverValue -import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticFunctionSymbol -import org.jetbrains.kotlin.fir.resolve.calls.ReceiverValue +import org.jetbrains.kotlin.fir.resolve.calls.* import org.jetbrains.kotlin.fir.resolve.providers.firProvider import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag @@ -140,6 +140,7 @@ abstract class FirVisibilityChecker : FirSessionComponent { ): Boolean { val symbol = declaration.symbol val provider = session.firProvider + return when (declaration.visibility) { Visibilities.Internal -> { declaration.moduleData == session.moduleData || session.moduleVisibilityChecker?.isInFriendModule(declaration) == true @@ -168,7 +169,13 @@ abstract class FirVisibilityChecker : FirSessionComponent { } else -> { // Member: visible inside parent class, including all its member classes - canSeePrivateMemberOf(containingDeclarations, ownerLookupTag, session) + canSeePrivateMemberOf( + containingDeclarations, + ownerLookupTag, + dispatchReceiver, + isVariableOrNamedFunction = symbol.isVariableOrNamedFunction(), + session + ) } } } else { @@ -180,7 +187,7 @@ abstract class FirVisibilityChecker : FirSessionComponent { val ownerId = symbol.getOwnerLookupTag() ownerId != null && canSeeProtectedMemberOf( containingDeclarations, dispatchReceiver, ownerId, session, - isVariableOrNamedFunction = symbol is FirVariableSymbol || symbol is FirNamedFunctionSymbol || symbol is FirPropertyAccessorSymbol, + isVariableOrNamedFunction = symbol.isVariableOrNamedFunction(), symbol.fir is FirSyntheticPropertyAccessor, supertypeSupplier ) @@ -213,21 +220,76 @@ abstract class FirVisibilityChecker : FirSessionComponent { private fun canSeePrivateMemberOf( containingDeclarationOfUseSite: List, ownerLookupTag: ConeClassLikeLookupTag, + dispatchReceiver: ReceiverValue?, + isVariableOrNamedFunction: Boolean, session: FirSession ): Boolean { ownerLookupTag.ownerIfCompanion(session)?.let { companionOwnerLookupTag -> - return canSeePrivateMemberOf(containingDeclarationOfUseSite, companionOwnerLookupTag, session) + return canSeePrivateMemberOf( + containingDeclarationOfUseSite, + companionOwnerLookupTag, + dispatchReceiver, + isVariableOrNamedFunction, + session + ) } - for (declaration in containingDeclarationOfUseSite) { - if (declaration !is FirClass) continue - val boundSymbol = declaration.symbol - if (boundSymbol.classId.isSame(ownerLookupTag.classId)) { - return true + fun matchWithContainingDeclarations(): Boolean { + for (declaration in containingDeclarationOfUseSite) { + if (declaration !is FirClass) continue + val boundSymbol = declaration.symbol + if (boundSymbol.classId.isSame(ownerLookupTag.classId)) { + return true + } } + return false } - return false + return if (isVariableOrNamedFunction && dispatchReceiver?.type is ConeClassLikeType) { + if (dispatchReceiver is ImplicitDispatchReceiverValue) { + val dispatchReceiverOwnerClassId = dispatchReceiver.ownerIfCompanion(session)?.classId ?: dispatchReceiver.type.classId + var isMemberFound = false + for (declaration in containingDeclarationOfUseSite) { + if (declaration !is FirClass) continue + + val boundSymbol = declaration.symbol + var isSameClasses = false + if (!isMemberFound) { + isSameClasses = boundSymbol.classId.isSame(ownerLookupTag.classId) + if (isSameClasses) { + isMemberFound = true + } + } + if (isMemberFound) { + if (!isSameClasses && !( + declaration.isInner || + (declaration.containingNonLocalClass(session) as? FirRegularClass)?.classKind == ClassKind.OBJECT) + ) { + // It should not be ordinary classes between use site and declaration + return false + } + if (boundSymbol.classId.isSame(dispatchReceiverOwnerClassId!!)) { + return true + } + } + } + isMemberFound + } else { + val receiverExpression = dispatchReceiver.receiverExpression + if (receiverExpression is FirThisReceiverExpression && + receiverExpression.source != null && + (containingDeclarationOfUseSite.lastOrNull() as? FirFunction)?.symbol?.isExtension != true + ) { + // Processing of explicit no extension `this` + val dispatchReceiverOwnerClassId = dispatchReceiver.ownerIfCompanion(session)?.classId ?: dispatchReceiver.type.classId + dispatchReceiverOwnerClassId?.isSame(ownerLookupTag.classId) == true + } else { + matchWithContainingDeclarations() + } + } + } else { + matchWithContainingDeclarations() + } } // 'local' isn't taken into account here @@ -350,7 +412,14 @@ abstract class FirVisibilityChecker : FirSessionComponent { isSyntheticProperty: Boolean, supertypeSupplier: SupertypeSupplier ): Boolean { - if (canSeePrivateMemberOf(containingDeclarationOfUseSite, ownerLookupTag, session)) return true + if (canSeePrivateMemberOf( + containingDeclarationOfUseSite, + ownerLookupTag, + dispatchReceiver, + isVariableOrNamedFunction, + session + ) + ) return true for (containingDeclaration in containingDeclarationOfUseSite) { if (containingDeclaration is FirClass) { @@ -405,3 +474,7 @@ fun FirBasedSymbol<*>.getOwnerLookupTag(): ConeClassLikeLookupTag? { else -> error("Unsupported owner search for ${fir.javaClass}: ${fir.render()}") } } + +fun FirBasedSymbol<*>.isVariableOrNamedFunction(): Boolean { + return this is FirVariableSymbol || this is FirNamedFunctionSymbol || this is FirPropertyAccessorSymbol +} \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/VisibilityUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/VisibilityUtils.kt index 2dcf16b7bc1..ff4fb41e58d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/VisibilityUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/VisibilityUtils.kt @@ -27,17 +27,17 @@ fun FirVisibilityChecker.isVisible( return isVisible(declaration.originalIfFakeOverride() as FirMemberDeclaration, candidate) } - val callInfo = candidate.callInfo - val useSiteFile = callInfo.containingFile - val containingDeclarations = callInfo.containingDeclarations - val session = callInfo.session - // We won't resolve into the backing field // in the first place, if it's not accessible. if (declaration is FirBackingField) { return true } + val callInfo = candidate.callInfo + val useSiteFile = callInfo.containingFile + val containingDeclarations = callInfo.containingDeclarations + val session = callInfo.session + val visible = isVisible( declaration, session, @@ -46,17 +46,19 @@ fun FirVisibilityChecker.isVisible( candidate.dispatchReceiverValue, candidate.callInfo.callSite is FirVariableAssignment ) - val backingField = declaration.getBackingFieldIfApplicable() - if (visible && backingField != null) { - candidate.hasVisibleBackingField = isVisible( - backingField, - session, - useSiteFile, - containingDeclarations, - candidate.dispatchReceiverValue, - candidate.callInfo.callSite is FirVariableAssignment, - ) + if (visible) { + val backingField = declaration.getBackingFieldIfApplicable() + if (backingField != null) { + candidate.hasVisibleBackingField = isVisible( + backingField, + session, + useSiteFile, + containingDeclarations, + candidate.dispatchReceiverValue, + candidate.callInfo.callSite is FirVariableAssignment, + ) + } } return visible @@ -67,10 +69,11 @@ private fun FirMemberDeclaration.getBackingFieldIfApplicable(): FirBackingField? // This check prevents resolving protected and // public fields. + val visibility = field.visibility if ( - field.visibility == Visibilities.PrivateToThis || - field.visibility == Visibilities.Private || - field.visibility == Visibilities.Internal + visibility == Visibilities.PrivateToThis || + visibility == Visibilities.Private || + visibility == Visibilities.Internal ) { return field } diff --git a/compiler/testData/codegen/box/objects/kt3684.kt b/compiler/testData/codegen/box/objects/kt3684.kt index 2b251f01f06..53e742f1764 100644 --- a/compiler/testData/codegen/box/objects/kt3684.kt +++ b/compiler/testData/codegen/box/objects/kt3684.kt @@ -1,6 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// FIR status: NPE: null cannot be cast to not-null type IrPropertySymbol -// while translating this@R|/|.R|/X.n| open class X(private val n: String) { fun foo(): String { diff --git a/compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.fir.kt b/compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.fir.kt new file mode 100644 index 00000000000..895bf2ac9c1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.fir.kt @@ -0,0 +1,76 @@ +// KT-49992 + +import kotlin.reflect.KFunction0 + +open class A { + private val x: String? = null + + fun test0() { + x + this.x + } + + open class Nested : A() { + private val y: String? = null + + fun test1(): String? = x + fun test2(): String? = this.x + + class NestedInNested : Nested() { + fun test20(): String? = y + fun test21(): String? = this.y + } + + inner class InnerInNested : Nested() { + fun test23(): String? = y + fun test24(): String? = this.y + } + } + + interface I { + fun test401(): KFunction0 + } + + open inner class Inner : A(), I { + private val y: String? = null + + fun test3(): String? = x + fun test4(): String? = this.x + + inner class InnerInInner : Inner() { + fun test40(): String? = x + fun test41(): String? = y + } + + private fun test400() { + } + + override fun test401(): KFunction0 { + return this::test400 + } + } + + fun test5() { + object : A() { + fun local() { + x + this.x + } + + inner class NestedInAnonymous() { + fun test50(): String? = x + } + } + } +} + +fun A.extensionFun(): String? = this.x + +abstract class B> { + protected abstract val thisBuilder: T + private val x: String? = null + + fun test6(obj: Any?) = thisBuilder.apply { + obj?.let { this.x } + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.kt b/compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.kt new file mode 100644 index 00000000000..171f2e9f0ed --- /dev/null +++ b/compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.kt @@ -0,0 +1,76 @@ +// KT-49992 + +import kotlin.reflect.KFunction0 + +open class A { + private val x: String? = null + + fun test0() { + x + this.x + } + + open class Nested : A() { + private val y: String? = null + + fun test1(): String? = x + fun test2(): String? = this.x + + class NestedInNested : Nested() { + fun test20(): String? = y + fun test21(): String? = this.y + } + + inner class InnerInNested : Nested() { + fun test23(): String? = y + fun test24(): String? = this.y + } + } + + interface I { + fun test401(): KFunction0 + } + + open inner class Inner : A(), I { + private val y: String? = null + + fun test3(): String? = x + fun test4(): String? = this.x + + inner class InnerInInner : Inner() { + fun test40(): String? = x + fun test41(): String? = y + } + + private fun test400() { + } + + override fun test401(): KFunction0 { + return this::test400 + } + } + + fun test5() { + object : A() { + fun local() { + x + this.x + } + + inner class NestedInAnonymous() { + fun test50(): String? = x + } + } + } +} + +fun A.extensionFun(): String? = this.x + +abstract class B> { + protected abstract val thisBuilder: T + private val x: String? = null + + fun test6(obj: Any?) = thisBuilder.apply { + obj?.let { this.x } + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.txt b/compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.txt new file mode 100644 index 00000000000..296e9d6f183 --- /dev/null +++ b/compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.txt @@ -0,0 +1,106 @@ +package + +public fun A.extensionFun(): kotlin.String? + +public open class A { + public constructor A() + private final val x: kotlin.String? = null + 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 test0(): kotlin.Unit + public final fun test5(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public interface I { + 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 abstract fun test401(): kotlin.reflect.KFunction0 + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open inner class Inner : A, A.I { + public constructor Inner() + invisible_fake final override /*1*/ /*fake_override*/ val x: kotlin.String? + private final val y: kotlin.String? = null + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun test0(): kotlin.Unit + public final fun test3(): kotlin.String? + public final fun test4(): kotlin.String? + private final fun test400(): kotlin.Unit + public open override /*1*/ fun test401(): kotlin.reflect.KFunction0 + public final override /*1*/ /*fake_override*/ fun test5(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + + public final inner class InnerInInner : A.Inner { + public constructor InnerInInner() + invisible_fake final override /*1*/ /*fake_override*/ val x: kotlin.String? + invisible_fake final override /*1*/ /*fake_override*/ val y: kotlin.String? + 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 override /*1*/ /*fake_override*/ fun test0(): kotlin.Unit + public final override /*1*/ /*fake_override*/ fun test3(): kotlin.String? + public final override /*1*/ /*fake_override*/ fun test4(): kotlin.String? + public final fun test40(): kotlin.String? + invisible_fake final override /*1*/ /*fake_override*/ fun test400(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun test401(): kotlin.reflect.KFunction0 + public final fun test41(): kotlin.String? + public final override /*1*/ /*fake_override*/ fun test5(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public open class Nested : A { + public constructor Nested() + invisible_fake final override /*1*/ /*fake_override*/ val x: kotlin.String? + private final val y: kotlin.String? = null + 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 override /*1*/ /*fake_override*/ fun test0(): kotlin.Unit + public final fun test1(): kotlin.String? + public final fun test2(): kotlin.String? + public final override /*1*/ /*fake_override*/ fun test5(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final inner class InnerInNested : A.Nested { + public constructor InnerInNested() + invisible_fake final override /*1*/ /*fake_override*/ val x: kotlin.String? + invisible_fake final override /*1*/ /*fake_override*/ val y: kotlin.String? + 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 override /*1*/ /*fake_override*/ fun test0(): kotlin.Unit + public final override /*1*/ /*fake_override*/ fun test1(): kotlin.String? + public final override /*1*/ /*fake_override*/ fun test2(): kotlin.String? + public final fun test23(): kotlin.String? + public final fun test24(): kotlin.String? + public final override /*1*/ /*fake_override*/ fun test5(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class NestedInNested : A.Nested { + public constructor NestedInNested() + invisible_fake final override /*1*/ /*fake_override*/ val x: kotlin.String? + invisible_fake final override /*1*/ /*fake_override*/ val y: kotlin.String? + 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 override /*1*/ /*fake_override*/ fun test0(): kotlin.Unit + public final override /*1*/ /*fake_override*/ fun test1(): kotlin.String? + public final override /*1*/ /*fake_override*/ fun test2(): kotlin.String? + public final fun test20(): kotlin.String? + public final fun test21(): kotlin.String? + public final override /*1*/ /*fake_override*/ fun test5(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } +} + +public abstract class B> { + public constructor B>() + protected abstract val thisBuilder: T + private final val x: kotlin.String? = null + 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 test6(/*0*/ obj: kotlin.Any?): T + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 9a1cb321cc0..60429b3df38 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -32721,6 +32721,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("innerNestedAndAnonymousClasses.kt") + public void testInnerNestedAndAnonymousClasses() throws Exception { + runTest("compiler/testData/diagnostics/tests/visibility/innerNestedAndAnonymousClasses.kt"); + } + @Test @TestMetadata("invisibleSetterOfJavaClass.kt") public void testInvisibleSetterOfJavaClass() throws Exception {