[K/N] Header klibs: Keep private properties in value classes
^KT-61767 Fixed
This commit is contained in:
+2
-1
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.metadata.serialization.MutableVersionRequirementTabl
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.isInlineClass
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer.Companion.sort
|
||||
@@ -41,7 +42,7 @@ class KlibMetadataSerializerExtension(
|
||||
DescriptorUtils.getAllDescriptors(classDescriptor.defaultType.memberScope)
|
||||
.filterIsInstance<CallableMemberDescriptor>()
|
||||
.filter { it.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE }
|
||||
.filter { it.visibility.isPublicAPI }
|
||||
.filter { it.visibility.isPublicAPI || classDescriptor.isInlineClass() }
|
||||
)
|
||||
}
|
||||
else super.customClassMembersProducer
|
||||
|
||||
+4
-9
@@ -163,15 +163,10 @@ class DescriptorSerializer private constructor(
|
||||
classDescriptor.inlineClassRepresentation?.let { inlineClassRepresentation ->
|
||||
builder.inlineClassUnderlyingPropertyName = getSimpleNameIndex(inlineClassRepresentation.underlyingPropertyName)
|
||||
|
||||
// The underlying property might be missing from `callableMembers` if we are producing a header klib and
|
||||
// the inline class is a part of the public API but the underlying property is not.
|
||||
val property = callableMembers.singleOrNull { candidate ->
|
||||
candidate is PropertyDescriptor
|
||||
&& candidate.extensionReceiverParameter == null
|
||||
&& candidate.name == inlineClassRepresentation.underlyingPropertyName
|
||||
} ?: return@let
|
||||
|
||||
if (property.visibility.isPublicAPI) {
|
||||
val property = callableMembers.single {
|
||||
it is PropertyDescriptor && it.extensionReceiverParameter == null && it.name == inlineClassRepresentation.underlyingPropertyName
|
||||
}
|
||||
if (!property.visibility.isPublicAPI) {
|
||||
if (useTypeTable()) {
|
||||
builder.inlineClassUnderlyingTypeId = typeId(inlineClassRepresentation.underlyingType)
|
||||
} else {
|
||||
|
||||
+3
-1
@@ -28,4 +28,6 @@ class B : A() {
|
||||
companion object {
|
||||
const val bConst: Int = 90
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
value class C(private val b: String)
|
||||
+5
@@ -31,10 +31,15 @@ fun useB(b: B) {
|
||||
B.bConst
|
||||
}
|
||||
|
||||
fun useC(b: String) {
|
||||
C(b)
|
||||
}
|
||||
|
||||
fun runAppAndReturnOk(): String {
|
||||
useI(A())
|
||||
useA(A())
|
||||
useB(B())
|
||||
useC("test")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user