Fix condition in calculation of adapted function reference flags

This only affects flags which are passed to
kotlin.jvm.internal.AdaptedFunctionReference. The only way it could lead
to changes in behavior is if it affected equals/hashCode of adapted
references. But it doesn't seem possible to construct a test where two
_different_ adaptations exist for a function reference to a
vararg-taking function, both of which use some sort of 1.4 function
reference conversion. Hence, no new tests are added.
This commit is contained in:
Alexander Udalov
2020-04-06 19:28:32 +02:00
parent 0681231e99
commit 66995fe1a5
@@ -561,8 +561,13 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
for (int i = shift;
i < anonymousAdaptedFunction.getValueParameters().size() && i - shift < target.getValueParameters().size();
i++) {
KotlinType varargElementType = target.getValueParameters().get(i - shift).getVarargElementType();
if (varargElementType != null && !varargElementType.equals(anonymousAdaptedFunction.getValueParameters().get(i).getType())) {
ValueParameterDescriptor targetParameter = target.getValueParameters().get(i - shift);
ValueParameterDescriptor adaptedParameter = anonymousAdaptedFunction.getValueParameters().get(i);
// Vararg to element conversion is happening if the target parameter is vararg (e.g. `vararg xs: Int`),
// but the adapted parameter's type is not equal to the target parameter's type (which is `IntArray`).
if (targetParameter.getVarargElementType() != null &&
!targetParameter.getType().equals(adaptedParameter.getType())) {
hasVarargMappedToElement = true;
break;
}