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