Generate stub for specialized equals inside inline class
This commit is contained in:
@@ -77,6 +77,7 @@ class ErasedInlineClassBodyCodegen(
|
||||
|
||||
generateUnboxMethod()
|
||||
generateFunctionsFromAny()
|
||||
generateSpecializedEqualsStub()
|
||||
}
|
||||
|
||||
private fun generateFunctionsFromAny() {
|
||||
@@ -116,6 +117,31 @@ class ErasedInlineClassBodyCodegen(
|
||||
)
|
||||
}
|
||||
|
||||
private fun generateSpecializedEqualsStub() {
|
||||
val specializedEqualsDescriptor = InlineClassDescriptorResolver.createSpecializedEqualsDescriptor(descriptor) ?: return
|
||||
|
||||
functionCodegen.generateMethod(
|
||||
Synthetic(null, specializedEqualsDescriptor), specializedEqualsDescriptor, object : FunctionGenerationStrategy.CodegenBased(state) {
|
||||
override fun mapMethodSignature(
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
typeMapper: KotlinTypeMapper,
|
||||
contextKind: OwnerKind,
|
||||
hasSpecialBridge: Boolean
|
||||
): JvmMethodGenericSignature {
|
||||
// we shouldn't use default mapping here to avoid adding parameter that relates to carrier type
|
||||
return typeMapper.mapSignatureForSpecializedEqualsOfInlineClass(functionDescriptor)
|
||||
}
|
||||
|
||||
|
||||
override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) {
|
||||
val iv = codegen.v
|
||||
iv.aconst(null)
|
||||
iv.athrow()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun generateKotlinMetadataAnnotation() {
|
||||
writeSyntheticClassMetadata(v, state)
|
||||
}
|
||||
|
||||
@@ -1162,6 +1162,11 @@ public class KotlinTypeMapper {
|
||||
return mapSignature(f, OwnerKind.IMPLEMENTATION, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JvmMethodGenericSignature mapSignatureForSpecializedEqualsOfInlineClass(@NotNull FunctionDescriptor f) {
|
||||
return mapSignature(f, OwnerKind.IMPLEMENTATION, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JvmMethodSignature mapSignatureSkipGeneric(@NotNull FunctionDescriptor f, @NotNull OwnerKind kind) {
|
||||
return mapSignature(f, kind, true);
|
||||
|
||||
Reference in New Issue
Block a user