Exclude private typealiases from ABI classes
This commit is contained in:
+4
@@ -55,6 +55,10 @@ class JvmSerializerExtension(private val bindings: JvmSerializationBindings, sta
|
|||||||
return classBuilderMode != ClassBuilderMode.ABI || descriptor.visibility != Visibilities.PRIVATE
|
return classBuilderMode != ClassBuilderMode.ABI || descriptor.visibility != Visibilities.PRIVATE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun shouldSerializeTypeAlias(descriptor: TypeAliasDescriptor): Boolean {
|
||||||
|
return classBuilderMode != ClassBuilderMode.ABI || descriptor.visibility != Visibilities.PRIVATE
|
||||||
|
}
|
||||||
|
|
||||||
override fun serializeClass(
|
override fun serializeClass(
|
||||||
descriptor: ClassDescriptor,
|
descriptor: ClassDescriptor,
|
||||||
proto: ProtoBuf.Class.Builder,
|
proto: ProtoBuf.Class.Builder,
|
||||||
|
|||||||
+5
-3
@@ -116,7 +116,7 @@ class DescriptorSerializer private constructor(
|
|||||||
val nestedClassifiers = sort(DescriptorUtils.getAllDescriptors(classDescriptor.unsubstitutedInnerClassesScope))
|
val nestedClassifiers = sort(DescriptorUtils.getAllDescriptors(classDescriptor.unsubstitutedInnerClassesScope))
|
||||||
for (descriptor in nestedClassifiers) {
|
for (descriptor in nestedClassifiers) {
|
||||||
if (descriptor is TypeAliasDescriptor) {
|
if (descriptor is TypeAliasDescriptor) {
|
||||||
builder.addTypeAlias(typeAliasProto(descriptor))
|
typeAliasProto(descriptor)?.let { builder.addTypeAlias(it) }
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val name = getSimpleNameIndex(descriptor.name)
|
val name = getSimpleNameIndex(descriptor.name)
|
||||||
@@ -406,7 +406,9 @@ class DescriptorSerializer private constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun typeAliasProto(descriptor: TypeAliasDescriptor): ProtoBuf.TypeAlias.Builder {
|
private fun typeAliasProto(descriptor: TypeAliasDescriptor): ProtoBuf.TypeAlias.Builder? {
|
||||||
|
if (!extension.shouldSerializeTypeAlias(descriptor)) return null
|
||||||
|
|
||||||
val builder = ProtoBuf.TypeAlias.newBuilder()
|
val builder = ProtoBuf.TypeAlias.newBuilder()
|
||||||
val local = createChildSerializer(descriptor)
|
val local = createChildSerializer(descriptor)
|
||||||
|
|
||||||
@@ -644,7 +646,7 @@ class DescriptorSerializer private constructor(
|
|||||||
when (declaration) {
|
when (declaration) {
|
||||||
is PropertyDescriptor -> propertyProto(declaration)?.let { builder.addProperty(it) }
|
is PropertyDescriptor -> propertyProto(declaration)?.let { builder.addProperty(it) }
|
||||||
is FunctionDescriptor -> functionProto(declaration)?.let { builder.addFunction(it) }
|
is FunctionDescriptor -> functionProto(declaration)?.let { builder.addFunction(it) }
|
||||||
is TypeAliasDescriptor -> builder.addTypeAlias(typeAliasProto(declaration))
|
is TypeAliasDescriptor -> typeAliasProto(declaration)?.let { builder.addTypeAlias(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ abstract class SerializerExtension {
|
|||||||
open fun shouldUseNormalizedVisibility(): Boolean = false
|
open fun shouldUseNormalizedVisibility(): Boolean = false
|
||||||
open fun shouldSerializeFunction(descriptor: FunctionDescriptor): Boolean = true
|
open fun shouldSerializeFunction(descriptor: FunctionDescriptor): Boolean = true
|
||||||
open fun shouldSerializeProperty(descriptor: PropertyDescriptor): Boolean = true
|
open fun shouldSerializeProperty(descriptor: PropertyDescriptor): Boolean = true
|
||||||
|
open fun shouldSerializeTypeAlias(descriptor: TypeAliasDescriptor): Boolean = true
|
||||||
|
|
||||||
interface ClassMembersProducer {
|
interface ClassMembersProducer {
|
||||||
fun getCallableMembers(classDescriptor: ClassDescriptor): Collection<CallableMemberDescriptor>
|
fun getCallableMembers(classDescriptor: ClassDescriptor): Collection<CallableMemberDescriptor>
|
||||||
|
|||||||
+5
@@ -54,6 +54,11 @@ public class CompareJvmAbiTestGenerated extends AbstractCompareJvmAbiTest {
|
|||||||
runTest("plugins/jvm-abi-gen/testData/compare/privateClass/");
|
runTest("plugins/jvm-abi-gen/testData/compare/privateClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateTypealias")
|
||||||
|
public void testPrivateTypealias() throws Exception {
|
||||||
|
runTest("plugins/jvm-abi-gen/testData/compare/privateTypealias/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("topLevelPrivateMembers")
|
@TestMetadata("topLevelPrivateMembers")
|
||||||
public void testTopLevelPrivateMembers() throws Exception {
|
public void testTopLevelPrivateMembers() throws Exception {
|
||||||
runTest("plugins/jvm-abi-gen/testData/compare/topLevelPrivateMembers/");
|
runTest("plugins/jvm-abi-gen/testData/compare/topLevelPrivateMembers/");
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class PublicClass1
|
||||||
|
class PublicClass2
|
||||||
|
|
||||||
|
typealias PublicTypeAlias1 = PublicClass1
|
||||||
|
typealias PublicTypeAlias2 = PublicClass1
|
||||||
|
|
||||||
|
internal typealias InternalTypeAlias1 = PublicClass1
|
||||||
|
internal typealias InternalTypeAlias2 = PublicClass1
|
||||||
|
|
||||||
|
private typealias PrivateTypeAlias1 = PublicClass1
|
||||||
|
private typealias PrivateTypeAlias2 = PublicClass1
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class PublicClass1
|
||||||
|
class PublicClass2
|
||||||
|
|
||||||
|
typealias PublicTypeAlias1 = PublicClass1
|
||||||
|
typealias PublicTypeAlias2 = PublicClass1
|
||||||
|
|
||||||
|
internal typealias InternalTypeAlias1 = PublicClass1
|
||||||
|
internal typealias InternalTypeAlias2 = PublicClass1
|
||||||
|
|
||||||
|
private typealias PrivateTypeAlias1 = PublicClass2
|
||||||
Reference in New Issue
Block a user