Generate metadata and annotations for hidden constructor

Reflection expects to see a callable method for a hidden constructor,
thus, it should be a synthetic accessor.
JVM method signature in metadata should point to the synthetic accessor.
Annotations for hidden constructor should be written on the synthetic
accessor.
This commit is contained in:
Dmitry Petrov
2018-09-11 18:08:22 +03:00
parent 3e3ffd14a9
commit 792c5f8b3f
16 changed files with 219 additions and 12 deletions
@@ -17,13 +17,14 @@ import java.security.MessageDigest
import java.util.*
fun shouldHideConstructorDueToInlineClassTypeValueParameters(descriptor: CallableMemberDescriptor): Boolean {
if (descriptor !is ClassConstructorDescriptor) return false
if (Visibilities.isPrivate(descriptor.visibility)) return false
if (descriptor.constructedClass.isInline) return false
val constructorDescriptor = descriptor as? ClassConstructorDescriptor ?: return false
if (Visibilities.isPrivate(constructorDescriptor.visibility)) return false
if (constructorDescriptor.constructedClass.isInline) return false
if (DescriptorUtils.isSealedClass(constructorDescriptor.constructedClass)) return false
// TODO inner class in inline class
return descriptor.valueParameters.any { it.type.requiresFunctionNameMangling() }
return constructorDescriptor.valueParameters.any { it.type.requiresFunctionNameMangling() }
}
fun requiresFunctionNameMangling(valueParameterTypes: List<KotlinType>): Boolean {