[klib] Add an option to write out header klibs

The header klib is supposed to only contain the public abi of the module
similar to jvm-abi-gen. It is intended to be used as a dependency for other
klib compilations instead of the full klib for compilation avoidance.

^KT-60807
This commit is contained in:
Johan Bay
2023-05-09 14:29:21 +02:00
committed by Space Team
parent 829e0675f4
commit 0a612e4268
90 changed files with 1374 additions and 76 deletions
@@ -163,10 +163,15 @@ class DescriptorSerializer private constructor(
classDescriptor.inlineClassRepresentation?.let { inlineClassRepresentation ->
builder.inlineClassUnderlyingPropertyName = getSimpleNameIndex(inlineClassRepresentation.underlyingPropertyName)
val property = callableMembers.single {
it is PropertyDescriptor && it.extensionReceiverParameter == null && it.name == inlineClassRepresentation.underlyingPropertyName
}
if (!property.visibility.isPublicAPI) {
// 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) {
if (useTypeTable()) {
builder.inlineClassUnderlyingTypeId = typeId(inlineClassRepresentation.underlyingType)
} else {