DATACMNS-1338 - Calculate defaulting mask count in Kotlin default constructor resolution.
We now calculate the number of expected default masks to filter synthetic constructors that do not match the expected parameter count. A Kotlin constructor with argument defaulting generates a synthetic integer argument for every 32 constructor arguments. This is independent of the number of actual optional arguments. Previously, we used an non-exact check to consider constructors as default ones if they had at least two additional arguments. This caused the wrong constructor being used if the non-synthetic types matched the types of the default constructor.
This commit is contained in:
@@ -112,13 +112,12 @@ public class KotlinClassGeneratingEntityInstantiator extends ClassGeneratingEnti
|
||||
continue;
|
||||
}
|
||||
|
||||
// with a parameter count greater zero
|
||||
if (constructor.getParameterCount() == 0) {
|
||||
continue;
|
||||
}
|
||||
// candidates must contain at least two additional parameters (int, DefaultConstructorMarker).
|
||||
// Number of defaulting masks derives from the original constructor arg count
|
||||
int syntheticParameters = (constructor.getParameterCount() / Integer.SIZE) + 1
|
||||
+ /* DefaultConstructorMarker */ 1;
|
||||
|
||||
// candidates must contain at least two additional parameters (int, DefaultConstructorMarker)
|
||||
if (constructor.getParameterCount() + 2 > candidate.getParameterCount()) {
|
||||
if (constructor.getParameterCount() + syntheticParameters != candidate.getParameterCount()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user