Fixed a bug where DEFAULT_CONSTRUCTOR_MARKER appeared twice as an argument
#KT-27598 Fixed Co-authored-by: Alexander Udalov <alexander.udalov@jetbrains.com>
This commit is contained in:
committed by
Alexander Udalov
parent
5851f757f5
commit
a1b6c9f546
@@ -236,7 +236,15 @@ internal abstract class KDeclarationContainerImpl : ClassBasedDeclarationContain
|
||||
repeat((valueParameters.size + Integer.SIZE - 1) / Integer.SIZE) {
|
||||
result.add(Integer.TYPE)
|
||||
}
|
||||
result.add(if (isConstructor) DEFAULT_CONSTRUCTOR_MARKER else Any::class.java)
|
||||
|
||||
if (isConstructor) {
|
||||
// Constructors that include the value class as an argument will include DEFAULT_CONSTRUCTOR_MARKER as an argument,
|
||||
// regardless of whether there is a default argument.
|
||||
// On the other hand, when searching for the default constructor,
|
||||
// DEFAULT_CONSTRUCTOR_MARKER needs to be present only at the end, so it is removed here.
|
||||
result.remove(DEFAULT_CONSTRUCTOR_MARKER)
|
||||
result.add(DEFAULT_CONSTRUCTOR_MARKER)
|
||||
} else result.add(Any::class.java)
|
||||
}
|
||||
|
||||
private fun loadParameterTypes(desc: String): List<Class<*>> {
|
||||
|
||||
@@ -76,7 +76,7 @@ internal class KFunctionImpl private constructor(
|
||||
|
||||
when (member) {
|
||||
is Constructor<*> ->
|
||||
createConstructorCaller(member, descriptor)
|
||||
createConstructorCaller(member, descriptor, false)
|
||||
is Method -> when {
|
||||
!Modifier.isStatic(member.modifiers) ->
|
||||
createInstanceMethodCaller(member)
|
||||
@@ -112,7 +112,7 @@ internal class KFunctionImpl private constructor(
|
||||
|
||||
when (member) {
|
||||
is Constructor<*> ->
|
||||
createConstructorCaller(member, descriptor)
|
||||
createConstructorCaller(member, descriptor, true)
|
||||
is Method -> when {
|
||||
// Note that static $default methods for @JvmStatic functions are generated differently in objects and companion objects.
|
||||
// In objects, $default's signature does _not_ contain the additional object instance parameter,
|
||||
@@ -140,8 +140,10 @@ internal class KFunctionImpl private constructor(
|
||||
private fun createInstanceMethodCaller(member: Method) =
|
||||
if (isBound) CallerImpl.Method.BoundInstance(member, boundReceiver) else CallerImpl.Method.Instance(member)
|
||||
|
||||
private fun createConstructorCaller(member: Constructor<*>, descriptor: FunctionDescriptor): CallerImpl<Constructor<*>> {
|
||||
return if (shouldHideConstructorDueToInlineClassTypeValueParameters(descriptor)) {
|
||||
private fun createConstructorCaller(
|
||||
member: Constructor<*>, descriptor: FunctionDescriptor, isDefault: Boolean
|
||||
): CallerImpl<Constructor<*>> {
|
||||
return if (!isDefault && shouldHideConstructorDueToInlineClassTypeValueParameters(descriptor)) {
|
||||
if (isBound)
|
||||
CallerImpl.AccessorForHiddenBoundConstructor(member, boundReceiver)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user