DATACMNS-1402 - Fix invocation of default Kotlin constructor.

We now correctly calculate the number of defaulting masks used to represent constructor arguments. Previously, we've been one off which caused that Kotlin classes with 32/33 parameters weren't able to be instantiated.

We also now reuse KotlinDefaultMask to apply defaulting calculation and removed code duplicates.
This commit is contained in:
Mark Paluch
2018-10-04 14:19:55 +02:00
committed by Oliver Gierke
parent 42ee9448d9
commit fc4b2d1deb
5 changed files with 240 additions and 24 deletions

View File

@@ -24,14 +24,19 @@ import kotlin.reflect.KFunction;
import kotlin.reflect.KParameter;
import kotlin.reflect.KParameter.Kind;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* Value object representing defaulting masks used for Kotlin methods applying parameter defaulting.
*
* @author Mark Paluch
* @since 2.1
*/
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
class KotlinDefaultMask {
public class KotlinDefaultMask {
@Getter
private final int[] defaulting;
/**
@@ -46,6 +51,16 @@ class KotlinDefaultMask {
}
}
/**
* Return the number of defaulting masks required to represent the number of {@code arguments}.
*
* @param arguments number of method arguments.
* @return the number of defaulting masks required.
*/
public static int getMaskCount(int arguments) {
return ((arguments - 1) / Integer.SIZE) + 1;
}
/**
* Creates defaulting mask(s) used to invoke Kotlin {@literal default} methods that conditionally apply parameter
* values.