From ee91ee9403981a2ce4a7e8d304aee54e7c168a1b Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Mon, 5 Jun 2023 13:54:22 +0200 Subject: [PATCH] [FIR] Set publishedApiEffectiveVisibility on deserialized declarations #KT-58641 Fixed --- .../kotlin/test/LoadedMetadataDumpHandler.kt | 16 ++- ...rLoadK1CompiledJvmKotlinTestGenerated.java | 6 + ...rLoadK2CompiledJvmKotlinTestGenerated.java | 6 + .../deserialization/ClassDeserialization.kt | 4 + .../deserialization/FirMemberDeserializer.kt | 6 + ...LightTreeBlackBoxCodegenTestGenerated.java | 6 + .../FirPsiBlackBoxCodegenTestGenerated.java | 6 + .../JvmClassFileBasedSymbolProvider.kt | 13 +- .../resolve/transformers/FirStatusResolver.kt | 33 ++--- .../publishedApiEffectiveVisibility.kt | 132 +++++++++++++++++- .../FirDeclarationRendererWithAttributes.kt | 18 ++- ...clarationRendererWithFilteredAttributes.kt | 16 +++ .../publishedApi/inlineFromFriendModule.kt | 10 ++ .../visibility/PublishedApi.fir.k1.jvm.txt | 92 ++++++++++++ .../visibility/PublishedApi.fir.k2.jvm.txt | 92 ++++++++++++ .../visibility/PublishedApi.fir.k2.klib.txt | 92 ++++++++++++ .../compiledKotlin/visibility/PublishedApi.kt | 46 ++++++ .../visibility/PublishedApi.txt | 67 +++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 + .../IrBlackBoxCodegenTestGenerated.java | 6 + ...kBoxCodegenWithIrInlinerTestGenerated.java | 6 + .../directives/FirDiagnosticsDirectives.kt | 6 + .../LightAnalysisModeTestGenerated.java | 5 + .../jvm/compiler/LoadJavaTestGenerated.java | 5 + .../LoadKotlinWithTypeTableTestGenerated.java | 5 + .../compiler/ir/IrLoadJavaTestGenerated.java | 5 + .../LoadJavaUsingJavacTestGenerated.java | 5 + ...mRuntimeDescriptorLoaderTestGenerated.java | 5 + .../js/test/JsCodegenBoxTestGenerated.java | 6 + .../fir/FirJsCodegenBoxTestGenerated.java | 6 + ...irLoadK2CompiledJsKotlinTestGenerated.java | 6 + .../test/ir/IrJsCodegenBoxTestGenerated.java | 6 + .../ir/IrJsES6CodegenBoxTestGenerated.java | 6 + .../FirNativeCodegenBoxTestGenerated.java | 6 + .../FirNativeCodegenBoxTestNoPLGenerated.java | 6 + .../NativeCodegenBoxTestGenerated.java | 6 + .../NativeCodegenBoxTestNoPLGenerated.java | 6 + .../test/IrCodegenBoxWasmTestGenerated.java | 5 + 38 files changed, 737 insertions(+), 37 deletions(-) create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRendererWithFilteredAttributes.kt create mode 100644 compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt create mode 100644 compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k1.jvm.txt create mode 100644 compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k2.jvm.txt create mode 100644 compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k2.klib.txt create mode 100644 compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt create mode 100644 compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.txt diff --git a/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/LoadedMetadataDumpHandler.kt b/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/LoadedMetadataDumpHandler.kt index e14c36c2714..7d99300ffa1 100644 --- a/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/LoadedMetadataDumpHandler.kt +++ b/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/LoadedMetadataDumpHandler.kt @@ -20,6 +20,8 @@ import org.jetbrains.kotlin.fir.DependencyListForCliModule import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration import org.jetbrains.kotlin.fir.declarations.utils.nameOrSpecialName +import org.jetbrains.kotlin.fir.renderer.FirDeclarationRenderer +import org.jetbrains.kotlin.fir.renderer.FirDeclarationRendererWithFilteredAttributes import org.jetbrains.kotlin.fir.renderer.FirRenderer import org.jetbrains.kotlin.fir.resolve.providers.firProvider import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider @@ -175,8 +177,9 @@ abstract class AbstractLoadedMetadataDumpHandler ).single().session val packageFqName = FqName("test") + val printAttributes = FirDiagnosticsDirectives.RENDER_FIR_DECLARATION_ATTRIBUTES in module.directives dumper.builderForModule(module) - .append(collectPackageContent(session, packageFqName, extractNames(module, packageFqName))) + .append(collectPackageContent(session, packageFqName, extractNames(module, packageFqName), printAttributes)) } protected abstract val targetPlatform: TargetPlatform @@ -296,11 +299,18 @@ abstract class AbstractLoadedMetadataDumpHandler } } - private fun collectPackageContent(session: FirSession, packageFqName: FqName, declarationNames: Collection): String { + private fun collectPackageContent(session: FirSession, packageFqName: FqName, declarationNames: Collection, printAttributes: Boolean): String { val provider = session.symbolProvider val builder = StringBuilder() - val firRenderer = FirRenderer(builder) + val firRenderer = FirRenderer( + builder, + declarationRenderer = if (printAttributes) { + FirDeclarationRendererWithFilteredAttributes() + } else { + FirDeclarationRenderer() + } + ) for (name in declarationNames) { for (symbol in provider.getTopLevelCallableSymbols(packageFqName, name)) { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLoadK1CompiledJvmKotlinTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLoadK1CompiledJvmKotlinTestGenerated.java index 3d55b2837db..35c67cb6d8b 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLoadK1CompiledJvmKotlinTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLoadK1CompiledJvmKotlinTestGenerated.java @@ -3202,6 +3202,12 @@ public class FirLoadK1CompiledJvmKotlinTestGenerated extends AbstractFirLoadK1Co runTest("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructorExplicitVisibility.kt"); } + @Test + @TestMetadata("PublishedApi.kt") + public void testPublishedApi() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt"); + } + @Test @TestMetadata("TopLevelVarWithPrivateSetter.kt") public void testTopLevelVarWithPrivateSetter() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLoadK2CompiledJvmKotlinTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLoadK2CompiledJvmKotlinTestGenerated.java index 144d6ffcaeb..1520b5c4fd3 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLoadK2CompiledJvmKotlinTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLoadK2CompiledJvmKotlinTestGenerated.java @@ -3202,6 +3202,12 @@ public class FirLoadK2CompiledJvmKotlinTestGenerated extends AbstractFirLoadK2Co runTest("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructorExplicitVisibility.kt"); } + @Test + @TestMetadata("PublishedApi.kt") + public void testPublishedApi() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt"); + } + @Test @TestMetadata("TopLevelVarWithPrivateSetter.kt") public void testTopLevelVarWithPrivateSetter() throws Exception { diff --git a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt index 797afd2492e..0d09f0ef686 100644 --- a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt +++ b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.declarations.utils.moduleName import org.jetbrains.kotlin.fir.declarations.utils.sourceElement import org.jetbrains.kotlin.fir.resolve.providers.getRegularClassSymbolByClassId import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider +import org.jetbrains.kotlin.fir.resolve.transformers.setLazyPublishedVisibility import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.fir.symbols.impl.FirEnumEntrySymbol @@ -114,6 +115,7 @@ fun deserializeClassToSymbol( context.annotationDeserializer.inheritAnnotationInfo(it.annotationDeserializer) } } + buildRegularClass { this.moduleData = moduleData this.origin = origin @@ -242,6 +244,8 @@ fun deserializeClassToSymbol( if (!Flags.HAS_ENUM_ENTRIES.get(flags)) { hasNoEnumEntriesAttr = true } + + setLazyPublishedVisibility(session) } } diff --git a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt index fec6a010ca2..70d8bf14086 100644 --- a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt +++ b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotation import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionStub import org.jetbrains.kotlin.fir.resolve.defaultType +import org.jetbrains.kotlin.fir.resolve.transformers.setLazyPublishedVisibility import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.toEffectiveVisibility @@ -467,6 +468,9 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) { proto.contextReceiverTypes(c.typeTable).mapTo(contextReceivers, ::loadContextReceiver) }.apply { versionRequirementsTable = c.versionRequirementTable + setLazyPublishedVisibility(c.session) + getter?.setLazyPublishedVisibility(annotations, this, c.session) + setter?.setLazyPublishedVisibility(annotations, this, c.session) } } @@ -552,6 +556,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) { proto.contextReceiverTypes(c.typeTable).mapTo(contextReceivers, ::loadContextReceiver) }.apply { versionRequirementsTable = c.versionRequirementTable + setLazyPublishedVisibility(c.session) } if (proto.hasContract()) { val contractDeserializer = if (proto.typeParameterList.isEmpty()) this.contractDeserializer else FirContractDeserializer(local) @@ -635,6 +640,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) { }.build().apply { containingClassForStaticMemberAttr = c.dispatchReceiver!!.lookupTag versionRequirementsTable = c.versionRequirementTable + setLazyPublishedVisibility(c.session) } } diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index 6ac2bb7c9e2..2072807b214 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -37387,6 +37387,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("noMangling.kt") public void testNoMangling() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 1fcced9b3ed..c5f49e720ac 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -37387,6 +37387,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("noMangling.kt") public void testNoMangling() throws Exception { diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/JvmClassFileBasedSymbolProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/JvmClassFileBasedSymbolProvider.kt index 9f7e9f60687..1cf29b0ad9a 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/JvmClassFileBasedSymbolProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/JvmClassFileBasedSymbolProvider.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotation import org.jetbrains.kotlin.fir.java.FirJavaFacade import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass import org.jetbrains.kotlin.fir.languageVersionSettings +import org.jetbrains.kotlin.fir.resolve.transformers.setLazyPublishedVisibility import org.jetbrains.kotlin.fir.scopes.FirKotlinScopeProvider import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.load.kotlin.* @@ -27,6 +28,7 @@ import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.resolve.jvm.JvmClassName import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol @@ -159,9 +161,13 @@ class JvmClassFileBasedSymbolProvider( symbol: FirRegularClassSymbol ) { val annotations = mutableListOf() + var hasPublishedApi = false kotlinClass.kotlinJvmBinaryClass.loadClassAnnotations( object : KotlinJvmBinaryClass.AnnotationVisitor { override fun visitAnnotation(classId: ClassId, source: SourceElement): KotlinJvmBinaryClass.AnnotationArgumentVisitor? { + if (classId == StandardClassIds.Annotations.PublishedApi) { + hasPublishedApi = true + } return annotationsLoader.loadAnnotationIfNotSpecial(classId, annotations) } @@ -170,8 +176,11 @@ class JvmClassFileBasedSymbolProvider( }, kotlinClass.byteContent, ) - symbol.fir.replaceAnnotations(annotations.toMutableOrEmpty()) - symbol.fir.replaceDeprecationsProvider(symbol.fir.getDeprecationsProvider(session)) + symbol.fir.run { + replaceAnnotations(annotations.toMutableOrEmpty()) + replaceDeprecationsProvider(symbol.fir.getDeprecationsProvider(session)) + setLazyPublishedVisibility(hasPublishedApi, null, session) + } } private fun String?.toPath(): Path? { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolver.kt index 0b4e4035070..5e29701355d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolver.kt @@ -26,9 +26,7 @@ import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope import org.jetbrains.kotlin.fir.toEffectiveVisibility import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.visibilityChecker -import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.types.Variance -import org.jetbrains.kotlin.utils.addToStdlib.runIf class FirStatusResolver( val session: FirSession, @@ -290,28 +288,23 @@ class FirStatusResolver( ) val effectiveVisibility = parentEffectiveVisibility.lowerBound(selfEffectiveVisibility, session.typeContext) val annotations = (containingProperty ?: declaration).annotations - - val hasPublishedApiAnnotation = annotations.any { - it.typeRef.coneTypeSafe()?.lookupTag?.classId == StandardClassIds.Annotations.PublishedApi - } - - var selfPublishedEffectiveVisibility = runIf(hasPublishedApiAnnotation) { - visibility.toEffectiveVisibility( - containingClass?.symbol?.toLookupTag(), forClass = declaration is FirClass, ownerIsPublishedApi = true - ) - } - var parentPublishedEffectiveVisibility = when { + val parentPublishedEffectiveVisibility = when { containingProperty != null -> containingProperty.publishedApiEffectiveVisibility containingClass is FirRegularClass -> containingClass.publishedApiEffectiveVisibility else -> null } - if (selfPublishedEffectiveVisibility != null || parentPublishedEffectiveVisibility != null) { - selfPublishedEffectiveVisibility = selfPublishedEffectiveVisibility ?: selfEffectiveVisibility - parentPublishedEffectiveVisibility = parentPublishedEffectiveVisibility ?: parentEffectiveVisibility - declaration.publishedApiEffectiveVisibility = parentPublishedEffectiveVisibility.lowerBound( - selfPublishedEffectiveVisibility, - session.typeContext - ) + + computePublishedApiEffectiveVisibility( + annotations, + visibility, + selfEffectiveVisibility, + containingClass?.symbol, + parentEffectiveVisibility, + parentPublishedEffectiveVisibility, + declaration is FirClass, + session + )?.let { + declaration.nonLazyPublishedApiEffectiveVisibility = it } if (containingClass is FirRegularClass && containingClass.isExpect) { diff --git a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/transformers/publishedApiEffectiveVisibility.kt b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/transformers/publishedApiEffectiveVisibility.kt index fcd8c72e8ef..d1ce2ea27ca 100644 --- a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/transformers/publishedApiEffectiveVisibility.kt +++ b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/transformers/publishedApiEffectiveVisibility.kt @@ -6,20 +6,140 @@ package org.jetbrains.kotlin.fir.resolve.transformers import org.jetbrains.kotlin.descriptors.EffectiveVisibility -import org.jetbrains.kotlin.fir.declarations.FirDeclaration -import org.jetbrains.kotlin.fir.declarations.FirDeclarationDataKey -import org.jetbrains.kotlin.fir.declarations.FirDeclarationDataRegistry -import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.utils.classId +import org.jetbrains.kotlin.fir.declarations.utils.effectiveVisibility +import org.jetbrains.kotlin.fir.expressions.FirAnnotation +import org.jetbrains.kotlin.fir.expressions.unexpandedClassId +import org.jetbrains.kotlin.fir.resolve.toSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.toEffectiveVisibility +import org.jetbrains.kotlin.fir.types.ConeClassLikeType +import org.jetbrains.kotlin.fir.types.coneTypeSafe +import org.jetbrains.kotlin.fir.types.toLookupTag +import org.jetbrains.kotlin.fir.types.typeContext +import org.jetbrains.kotlin.name.StandardClassIds +import org.jetbrains.kotlin.utils.addToStdlib.runIf private object PublishedApiEffectiveVisibilityKey : FirDeclarationDataKey() -var FirDeclaration.publishedApiEffectiveVisibility: EffectiveVisibility? by FirDeclarationDataRegistry.data(PublishedApiEffectiveVisibilityKey) +private object LazyPublishedApiEffectiveVisibilityKey : FirDeclarationDataKey() + +var FirDeclaration.nonLazyPublishedApiEffectiveVisibility: EffectiveVisibility? by FirDeclarationDataRegistry.data( + PublishedApiEffectiveVisibilityKey +) +var FirDeclaration.lazyPublishedApiEffectiveVisibility: Lazy? by FirDeclarationDataRegistry.data( + LazyPublishedApiEffectiveVisibilityKey +) + +val FirDeclaration.publishedApiEffectiveVisibility: EffectiveVisibility? + get() = nonLazyPublishedApiEffectiveVisibility ?: lazyPublishedApiEffectiveVisibility?.value inline val FirBasedSymbol<*>.publishedApiEffectiveVisibility: EffectiveVisibility? get() { lazyResolveToPhase(FirResolvePhase.STATUS) return fir.publishedApiEffectiveVisibility } + +fun computePublishedApiEffectiveVisibility( + annotations: List, + visibility: Visibility, + selfEffectiveVisibility: EffectiveVisibility, + containingClassSymbol: FirClassLikeSymbol<*>?, + parentEffectiveVisibility: EffectiveVisibility, + parentPublishedEffectiveVisibility: EffectiveVisibility?, + forClass: Boolean, + session: FirSession, +): EffectiveVisibility? { + val hasPublishedApiAnnotation = annotations.any { + it.typeRef.coneTypeSafe()?.lookupTag?.classId == StandardClassIds.Annotations.PublishedApi + } + + return computePublishedApiEffectiveVisibility( + hasPublishedApiAnnotation, + visibility, + selfEffectiveVisibility, + containingClassSymbol?.toLookupTag(), + parentEffectiveVisibility, + parentPublishedEffectiveVisibility, + forClass, + session + ) +} + +fun computePublishedApiEffectiveVisibility( + hasPublishedApiAnnotation: Boolean, + visibility: Visibility, + selfEffectiveVisibility: EffectiveVisibility, + containingClassLookupTag: ConeClassLikeLookupTag?, + parentEffectiveVisibility: EffectiveVisibility, + parentPublishedEffectiveVisibility: EffectiveVisibility?, + forClass: Boolean, + session: FirSession, +): EffectiveVisibility? { + val selfPublishedEffectiveVisibility = runIf(hasPublishedApiAnnotation) { + visibility.toEffectiveVisibility( + containingClassLookupTag, forClass = forClass, ownerIsPublishedApi = true + ) + } + + if (selfPublishedEffectiveVisibility != null || parentPublishedEffectiveVisibility != null) { + return (parentPublishedEffectiveVisibility ?: parentEffectiveVisibility).lowerBound( + (selfPublishedEffectiveVisibility ?: selfEffectiveVisibility), + session.typeContext + ) + } + + return null +} + +/** + * Published visibility depends on the published visibility of the containing class. + * However, the published visibility of deserialized classes can't be eagerly determined because it depends on their annotations, which + * are loaded later to prevent endless loops. + * To break up this dependency, the published visibility can be computed lazily when containing classes are fully deserialized. + */ +fun FirMemberDeclaration.setLazyPublishedVisibility(session: FirSession) { + setLazyPublishedVisibility(annotations, null, session) +} + +fun FirMemberDeclaration.setLazyPublishedVisibility(annotations: List, parentProperty: FirProperty?, session: FirSession) { + setLazyPublishedVisibility( + hasPublishedApi = annotations.any { it.unexpandedClassId == StandardClassIds.Annotations.PublishedApi }, + parentProperty, + session + ) +} + +fun FirMemberDeclaration.setLazyPublishedVisibility(hasPublishedApi: Boolean, parentProperty: FirProperty?, session: FirSession) { + if (!hasPublishedApi) return + + lazyPublishedApiEffectiveVisibility = lazy { + val containingClassLookupTag = (when { + parentProperty != null -> parentProperty.symbol.callableId.classId + this is FirClassLikeDeclaration -> classId.parentClassId + this is FirCallableDeclaration -> symbol.callableId.classId + else -> null + })?.toLookupTag() + + val status = status as FirResolvedDeclarationStatus + val parentSymbol = containingClassLookupTag?.toSymbol(session) + computePublishedApiEffectiveVisibility( + hasPublishedApiAnnotation = true, + visibility = status.visibility, + selfEffectiveVisibility = status.effectiveVisibility, + containingClassLookupTag = containingClassLookupTag, + parentEffectiveVisibility = parentProperty?.effectiveVisibility ?: parentSymbol?.effectiveVisibility + ?: EffectiveVisibility.Public, + parentPublishedEffectiveVisibility = parentProperty?.publishedApiEffectiveVisibility + ?: parentSymbol?.publishedApiEffectiveVisibility, + forClass = this is FirClass, + session = session, + ) + } +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRendererWithAttributes.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRendererWithAttributes.kt index b24c6430f82..6e022049815 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRendererWithAttributes.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRendererWithAttributes.kt @@ -14,25 +14,31 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol open class FirDeclarationRendererWithAttributes : FirDeclarationRenderer() { override fun FirDeclaration.renderDeclarationAttributes() { if (attributes.isNotEmpty()) { - val attributes = getAttributesWithValues().mapNotNull { (klass, value) -> - value?.let { klass to value.renderAsDeclarationAttributeValue() } - }.joinToString { (name, value) -> "$name=$value" } + val attributes = getAttributesWithValues() + .mapNotNull { (klass, value) -> value?.let { klass to value.renderAsDeclarationAttributeValue() } } + .ifEmpty { return } + .joinToString { (name, value) -> "$name=$value" } printer.print("[$attributes] ") } } private fun FirDeclaration.getAttributesWithValues(): List> { - val attributesMap = FirDeclarationDataRegistry.allValuesThreadUnsafeForRendering() - return attributesMap.entries - .map { it.key.substringAfterLast(".") to it.value } + return attributeTypesToIds() .sortedBy { it.first } .map { (klass, index) -> klass to attributes[index] } } + protected open fun attributeTypesToIds(): List> { + val attributeMap = FirDeclarationDataRegistry.allValuesThreadUnsafeForRendering() + return attributeMap.entries + .map { it.key.substringAfterLast(".") to it.value } + } + private fun Any.renderAsDeclarationAttributeValue() = when (this) { is FirCallableSymbol<*> -> callableId.toString() is FirClassLikeSymbol<*> -> classId.asString() is FirProperty -> symbol.callableId.toString() + is Lazy<*> -> value.toString() else -> toString() } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRendererWithFilteredAttributes.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRendererWithFilteredAttributes.kt new file mode 100644 index 00000000000..73a8e51fc71 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRendererWithFilteredAttributes.kt @@ -0,0 +1,16 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.renderer + +class FirDeclarationRendererWithFilteredAttributes : FirDeclarationRendererWithAttributes() { + override fun attributeTypesToIds(): List> { + return super.attributeTypesToIds().filter { it.first !in IGNORED_ATTRIBUTES } + } + + private companion object { + private val IGNORED_ATTRIBUTES = setOf("FirVersionRequirementsTableKey", "SourceElementKey") + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt b/compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt new file mode 100644 index 00000000000..5245b189110 --- /dev/null +++ b/compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt @@ -0,0 +1,10 @@ +// MODULE: lib +// FILE: lib.kt +@PublishedApi +internal fun published() = "OK" + +// MODULE: main()(lib)() +// FILE: main.kt +inline fun callTest() = published() + +fun box() = callTest() diff --git a/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k1.jvm.txt b/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k1.jvm.txt new file mode 100644 index 00000000000..28e176a425f --- /dev/null +++ b/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k1.jvm.txt @@ -0,0 +1,92 @@ +@R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] fun method(): R|kotlin/Unit| + +@PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop: R|kotlin/Int| + internal [LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + +@PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop2: R|kotlin/Int| + internal [LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + +@PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] var prop3: R|kotlin/Int| + internal [LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + internal [LazyPublishedApiEffectiveVisibilityKey=public] set(value: R|kotlin/Int|): R|kotlin/Unit| + +internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false] class Internal : R|kotlin/Any| { + @R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] fun method(): R|kotlin/Unit| + + public final val foo: R|kotlin/String| + public [ContainingClassKey=Internal] get(): R|kotlin/String| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] val prop: R|kotlin/Int| + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] val prop2: R|kotlin/Int| + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] var prop3: R|kotlin/Int| + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] get(): R|kotlin/Int| + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] set(value: R|kotlin/Int|): R|kotlin/Unit| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] constructor(): R|test/Internal| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] constructor(foo: R|kotlin/String|): R|test/Internal| + + @R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=internal] class Nested : R|kotlin/Any| { + public [ContainingClassKey=Nested] constructor(): R|test/Internal.Nested| + + } + +} + +public final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false] class Public : R|kotlin/Any| { + @R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] fun method(): R|kotlin/Unit| + + public final val foo: R|kotlin/String| + public [ContainingClassKey=Public] get(): R|kotlin/String| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop: R|kotlin/Int| + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop2: R|kotlin/Int| + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] var prop3: R|kotlin/Int| + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] set(value: R|kotlin/Int|): R|kotlin/Unit| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] constructor(): R|test/Public| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] constructor(foo: R|kotlin/String|): R|test/Public| + + @R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=public] class Nested : R|kotlin/Any| { + public [ContainingClassKey=Nested] constructor(): R|test/Public.Nested| + + } + +} + +@R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=public] class Published : R|kotlin/Any| { + @R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] fun method(): R|kotlin/Unit| + + public final val foo: R|kotlin/String| + public [ContainingClassKey=Published] get(): R|kotlin/String| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop: R|kotlin/Int| + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop2: R|kotlin/Int| + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] var prop3: R|kotlin/Int| + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] set(value: R|kotlin/Int|): R|kotlin/Unit| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] constructor(): R|test/Published| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] constructor(foo: R|kotlin/String|): R|test/Published| + + @R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=public] class Nested : R|kotlin/Any| { + public [ContainingClassKey=Nested] constructor(): R|test/Published.Nested| + + } + +} diff --git a/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k2.jvm.txt b/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k2.jvm.txt new file mode 100644 index 00000000000..5d2493744be --- /dev/null +++ b/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k2.jvm.txt @@ -0,0 +1,92 @@ +@R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] fun method(): R|kotlin/Unit| + +@PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop: R|kotlin/Int| + internal [LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + +@PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop2: R|kotlin/Int| + internal [LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + +@PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] var prop3: R|kotlin/Int| + internal [LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + internal [LazyPublishedApiEffectiveVisibilityKey=public] set(value: R|kotlin/Int|): R|kotlin/Unit| + +internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false] class Internal : R|kotlin/Any| { + @R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] fun method(): R|kotlin/Unit| + + public final val foo: R|kotlin/String| + public [ContainingClassKey=Internal] get(): R|kotlin/String| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] val prop: R|kotlin/Int| + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] val prop2: R|kotlin/Int| + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] var prop3: R|kotlin/Int| + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] get(): R|kotlin/Int| + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] set(value: R|kotlin/Int|): R|kotlin/Unit| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] constructor(foo: R|kotlin/String|): R|test/Internal| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] constructor(): R|test/Internal| + + @R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=internal] class Nested : R|kotlin/Any| { + public [ContainingClassKey=Nested] constructor(): R|test/Internal.Nested| + + } + +} + +public final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false] class Public : R|kotlin/Any| { + @R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] fun method(): R|kotlin/Unit| + + public final val foo: R|kotlin/String| + public [ContainingClassKey=Public] get(): R|kotlin/String| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop: R|kotlin/Int| + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop2: R|kotlin/Int| + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] var prop3: R|kotlin/Int| + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] set(value: R|kotlin/Int|): R|kotlin/Unit| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] constructor(foo: R|kotlin/String|): R|test/Public| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] constructor(): R|test/Public| + + @R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=public] class Nested : R|kotlin/Any| { + public [ContainingClassKey=Nested] constructor(): R|test/Public.Nested| + + } + +} + +@R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=public] class Published : R|kotlin/Any| { + @R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] fun method(): R|kotlin/Unit| + + public final val foo: R|kotlin/String| + public [ContainingClassKey=Published] get(): R|kotlin/String| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop: R|kotlin/Int| + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop2: R|kotlin/Int| + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] var prop3: R|kotlin/Int| + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] set(value: R|kotlin/Int|): R|kotlin/Unit| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] constructor(foo: R|kotlin/String|): R|test/Published| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] constructor(): R|test/Published| + + @R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=public] class Nested : R|kotlin/Any| { + public [ContainingClassKey=Nested] constructor(): R|test/Published.Nested| + + } + +} diff --git a/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k2.klib.txt b/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k2.klib.txt new file mode 100644 index 00000000000..c0444dfec01 --- /dev/null +++ b/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.fir.k2.klib.txt @@ -0,0 +1,92 @@ +@R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] fun method(): R|kotlin/Unit| + +@PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop: R|kotlin/Int| = Int(1) + internal [LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + +@PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop2: R|kotlin/Int| + internal [LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + +@PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] var prop3: R|kotlin/Int| + internal [LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + internal [LazyPublishedApiEffectiveVisibilityKey=public] set(value: R|kotlin/Int|): R|kotlin/Unit| + +internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false] class Internal : R|kotlin/Any| { + @R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] fun method(): R|kotlin/Unit| + + public final val foo: R|kotlin/String| + public [ContainingClassKey=Internal] get(): R|kotlin/String| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] val prop: R|kotlin/Int| = Int(1) + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] val prop2: R|kotlin/Int| + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=internal] var prop3: R|kotlin/Int| + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] get(): R|kotlin/Int| + internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] set(value: R|kotlin/Int|): R|kotlin/Unit| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] constructor(foo: R|kotlin/String|): R|test/Internal| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Internal, LazyPublishedApiEffectiveVisibilityKey=internal] constructor(): R|test/Internal| + + @R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=internal] class Nested : R|kotlin/Any| { + public [ContainingClassKey=Nested] constructor(): R|test/Internal.Nested| + + } + +} + +public final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false] class Public : R|kotlin/Any| { + @R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] fun method(): R|kotlin/Unit| + + public final val foo: R|kotlin/String| + public [ContainingClassKey=Public] get(): R|kotlin/String| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop: R|kotlin/Int| = Int(1) + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop2: R|kotlin/Int| + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] var prop3: R|kotlin/Int| + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] set(value: R|kotlin/Int|): R|kotlin/Unit| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] constructor(foo: R|kotlin/String|): R|test/Public| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Public, LazyPublishedApiEffectiveVisibilityKey=public] constructor(): R|test/Public| + + @R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=public] class Nested : R|kotlin/Any| { + public [ContainingClassKey=Nested] constructor(): R|test/Public.Nested| + + } + +} + +@R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=public] class Published : R|kotlin/Any| { + @R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] fun method(): R|kotlin/Unit| + + public final val foo: R|kotlin/String| + public [ContainingClassKey=Published] get(): R|kotlin/String| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop: R|kotlin/Int| = Int(1) + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] val prop2: R|kotlin/Int| + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + + @PROPERTY:R|kotlin/PublishedApi|() internal final [LazyPublishedApiEffectiveVisibilityKey=public] var prop3: R|kotlin/Int| + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] get(): R|kotlin/Int| + internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] set(value: R|kotlin/Int|): R|kotlin/Unit| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] constructor(foo: R|kotlin/String|): R|test/Published| + + @R|kotlin/PublishedApi|() internal [ContainingClassKey=Published, LazyPublishedApiEffectiveVisibilityKey=public] constructor(): R|test/Published| + + @R|kotlin/PublishedApi|() internal final [HasNoEnumEntriesKey=true, IsNewPlaceForBodyGeneration=false, LazyPublishedApiEffectiveVisibilityKey=public] class Nested : R|kotlin/Any| { + public [ContainingClassKey=Nested] constructor(): R|test/Published.Nested| + + } + +} diff --git a/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt b/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt new file mode 100644 index 00000000000..384133af60a --- /dev/null +++ b/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt @@ -0,0 +1,46 @@ +// RENDER_FIR_DECLARATION_ATTRIBUTES +// PLATFORM_DEPENDANT_METADATA +// NO_CHECK_SOURCE_VS_BINARY +// SKIP_IN_RUNTIME_TEST + +package test + +internal class Internal @PublishedApi internal constructor(val foo: String) { + @PublishedApi internal constructor() : this("") + @PublishedApi internal fun method() {} + @PublishedApi internal val prop: Int = 1 + @PublishedApi internal val prop2: Int get() = 1 + @PublishedApi internal var prop3: Int = 1 + set(value) {} + + @PublishedApi internal class Nested +} + +class Public @PublishedApi internal constructor(val foo: String) { + @PublishedApi internal constructor() : this("") + @PublishedApi internal fun method() {} + @PublishedApi internal val prop: Int = 1 + @PublishedApi internal val prop2: Int get() = 1 + @PublishedApi internal var prop3: Int = 1 + set(value) {} + + @PublishedApi internal class Nested +} + +@PublishedApi +internal class Published @PublishedApi internal constructor(val foo: String) { + @PublishedApi internal constructor() : this("") + @PublishedApi internal fun method() {} + @PublishedApi internal val prop: Int = 1 + @PublishedApi internal val prop2: Int get() = 1 + @PublishedApi internal var prop3: Int = 1 + set(value) {} + + @PublishedApi internal class Nested +} + +@PublishedApi internal fun method() {} +@PublishedApi internal val prop: Int = 1 +@PublishedApi internal val prop2: Int get() = 1 +@PublishedApi internal var prop3: Int = 1 + set(value) {} \ No newline at end of file diff --git a/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.txt b/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.txt new file mode 100644 index 00000000000..8da3381eaa1 --- /dev/null +++ b/compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.txt @@ -0,0 +1,67 @@ +package test + +@kotlin.PublishedApi internal val prop: kotlin.Int + internal fun ``(): kotlin.Int +@kotlin.PublishedApi internal val prop2: kotlin.Int + internal fun ``(): kotlin.Int +@kotlin.PublishedApi internal var prop3: kotlin.Int + internal fun ``(): kotlin.Int + internal fun ``(/*0*/ value: kotlin.Int): kotlin.Unit +@kotlin.PublishedApi internal fun method(): kotlin.Unit + +internal final class Internal { + @kotlin.PublishedApi internal constructor Internal() + /*primary*/ @kotlin.PublishedApi internal constructor Internal(/*0*/ foo: kotlin.String) + public final val foo: kotlin.String + public final fun ``(): kotlin.String + @kotlin.PublishedApi internal final val prop: kotlin.Int + internal final fun ``(): kotlin.Int + @kotlin.PublishedApi internal final val prop2: kotlin.Int + internal final fun ``(): kotlin.Int + @kotlin.PublishedApi internal final var prop3: kotlin.Int + internal final fun ``(): kotlin.Int + internal final fun ``(/*0*/ value: kotlin.Int): kotlin.Unit + @kotlin.PublishedApi internal final fun method(): kotlin.Unit + + @kotlin.PublishedApi internal final class Nested { + /*primary*/ public constructor Nested() + } +} + +public final class Public { + @kotlin.PublishedApi internal constructor Public() + /*primary*/ @kotlin.PublishedApi internal constructor Public(/*0*/ foo: kotlin.String) + public final val foo: kotlin.String + public final fun ``(): kotlin.String + @kotlin.PublishedApi internal final val prop: kotlin.Int + internal final fun ``(): kotlin.Int + @kotlin.PublishedApi internal final val prop2: kotlin.Int + internal final fun ``(): kotlin.Int + @kotlin.PublishedApi internal final var prop3: kotlin.Int + internal final fun ``(): kotlin.Int + internal final fun ``(/*0*/ value: kotlin.Int): kotlin.Unit + @kotlin.PublishedApi internal final fun method(): kotlin.Unit + + @kotlin.PublishedApi internal final class Nested { + /*primary*/ public constructor Nested() + } +} + +@kotlin.PublishedApi internal final class Published { + @kotlin.PublishedApi internal constructor Published() + /*primary*/ @kotlin.PublishedApi internal constructor Published(/*0*/ foo: kotlin.String) + public final val foo: kotlin.String + public final fun ``(): kotlin.String + @kotlin.PublishedApi internal final val prop: kotlin.Int + internal final fun ``(): kotlin.Int + @kotlin.PublishedApi internal final val prop2: kotlin.Int + internal final fun ``(): kotlin.Int + @kotlin.PublishedApi internal final var prop3: kotlin.Int + internal final fun ``(): kotlin.Int + internal final fun ``(/*0*/ value: kotlin.Int): kotlin.Unit + @kotlin.PublishedApi internal final fun method(): kotlin.Unit + + @kotlin.PublishedApi internal final class Nested { + /*primary*/ public constructor Nested() + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 2d3b7c95444..5764f4fa40a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -35611,6 +35611,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("noMangling.kt") public void testNoMangling() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index ef2a04dbc11..72c2261467c 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -37387,6 +37387,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("noMangling.kt") public void testNoMangling() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index 9454d882cc7..495982da1cb 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -37387,6 +37387,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("noMangling.kt") public void testNoMangling() throws Exception { diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt index 4827e2b1bd2..927806639e1 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt @@ -88,6 +88,12 @@ object FirDiagnosticsDirectives : SimpleDirectivesContainer() { See AbstractLoadedMetadataDumpHandler """ ) + + val RENDER_FIR_DECLARATION_ATTRIBUTES by directive( + description = """ + Prints declaration attributes to dumps in load compiled kotlin tests + """ + ) } fun TestConfigurationBuilder.configureFirParser(parser: FirParser) { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 48b4b790678..656163748e8 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -30462,6 +30462,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @TestMetadata("noMangling.kt") public void testNoMangling() throws Exception { runTest("compiler/testData/codegen/box/publishedApi/noMangling.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java index e5d8425424a..5846f7219d1 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java @@ -4554,6 +4554,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { runTest("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructorExplicitVisibility.kt"); } + @TestMetadata("PublishedApi.kt") + public void testPublishedApi() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt"); + } + @TestMetadata("TopLevelVarWithPrivateSetter.kt") public void testTopLevelVarWithPrivateSetter() throws Exception { runTest("compiler/testData/loadJava/compiledKotlin/visibility/TopLevelVarWithPrivateSetter.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java index 4b8c574cf51..30c78f999a5 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java @@ -2866,6 +2866,11 @@ public class LoadKotlinWithTypeTableTestGenerated extends AbstractLoadKotlinWith runTest("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructorExplicitVisibility.kt"); } + @TestMetadata("PublishedApi.kt") + public void testPublishedApi() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt"); + } + @TestMetadata("TopLevelVarWithPrivateSetter.kt") public void testTopLevelVarWithPrivateSetter() throws Exception { runTest("compiler/testData/loadJava/compiledKotlin/visibility/TopLevelVarWithPrivateSetter.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java index 0e7b798b4bd..48b6ac782f3 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java @@ -4555,6 +4555,11 @@ public class IrLoadJavaTestGenerated extends AbstractIrLoadJavaTest { runTest("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructorExplicitVisibility.kt"); } + @TestMetadata("PublishedApi.kt") + public void testPublishedApi() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt"); + } + @TestMetadata("TopLevelVarWithPrivateSetter.kt") public void testTopLevelVarWithPrivateSetter() throws Exception { runTest("compiler/testData/loadJava/compiledKotlin/visibility/TopLevelVarWithPrivateSetter.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java index 2f80b1254a4..b5265ec1300 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java @@ -4554,6 +4554,11 @@ public class LoadJavaUsingJavacTestGenerated extends AbstractLoadJavaUsingJavacT runTest("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructorExplicitVisibility.kt"); } + @TestMetadata("PublishedApi.kt") + public void testPublishedApi() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt"); + } + @TestMetadata("TopLevelVarWithPrivateSetter.kt") public void testTopLevelVarWithPrivateSetter() throws Exception { runTest("compiler/testData/loadJava/compiledKotlin/visibility/TopLevelVarWithPrivateSetter.kt"); diff --git a/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java b/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java index 58cc6cbcdd9..cb558742208 100644 --- a/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java +++ b/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java @@ -2868,6 +2868,11 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD runTest("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructorExplicitVisibility.kt"); } + @TestMetadata("PublishedApi.kt") + public void testPublishedApi() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt"); + } + @TestMetadata("TopLevelVarWithPrivateSetter.kt") public void testTopLevelVarWithPrivateSetter() throws Exception { runTest("compiler/testData/loadJava/compiledKotlin/visibility/TopLevelVarWithPrivateSetter.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 7b61aefa70a..c78a3a0df19 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -26437,6 +26437,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index 44d68eddd56..15a0caa54d7 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -26725,6 +26725,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLoadK2CompiledJsKotlinTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLoadK2CompiledJsKotlinTestGenerated.java index 2a4236220a4..035f5494ee4 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLoadK2CompiledJsKotlinTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLoadK2CompiledJsKotlinTestGenerated.java @@ -2836,6 +2836,12 @@ public class FirLoadK2CompiledJsKotlinTestGenerated extends AbstractFirLoadK2Com runTest("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructorExplicitVisibility.kt"); } + @Test + @TestMetadata("PublishedApi.kt") + public void testPublishedApi() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/visibility/PublishedApi.kt"); + } + @Test @TestMetadata("TopLevelVarWithPrivateSetter.kt") public void testTopLevelVarWithPrivateSetter() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 3f98d18d047..574567c4483 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -26725,6 +26725,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index e00e3f388ed..53396bf353c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -26725,6 +26725,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java index 91d000b2f60..28292cc4454 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java @@ -29866,6 +29866,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java index e0ec5cd3764..99a561e3421 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java @@ -30542,6 +30542,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 5463a023a03..2e00e878e0f 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -29529,6 +29529,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java index 9df14afd138..35dc28c0a4a 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java @@ -29867,6 +29867,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Test + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java index db0500f1d87..6dc38c6d99f 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java @@ -23700,6 +23700,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/publishedApi"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } + @TestMetadata("inlineFromFriendModule.kt") + public void testInlineFromFriendModule() throws Exception { + runTest("compiler/testData/codegen/box/publishedApi/inlineFromFriendModule.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/publishedApi/simple.kt");