Substitute type arguments of old callable references as well

This commit is contained in:
Victor Petukhov
2021-05-21 15:05:32 +03:00
parent d5be258291
commit 3ff22b67f7
@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.types.TypeSubstitutor;
import org.jetbrains.kotlin.types.Variance;
import java.util.*;
import java.util.stream.Collectors;
import static org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.INCOMPLETE_TYPE_INFERENCE;
import static org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.UNKNOWN_STATUS;
@@ -68,7 +69,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
private final TypeSubstitutor knownTypeParametersSubstitutor;
@NotNull
private final Map<TypeParameterDescriptor, KotlinType> typeArguments;
private Map<TypeParameterDescriptor, KotlinType> typeArguments;
@NotNull
private final Map<ValueParameterDescriptor, ResolvedValueArgument> valueArguments;
private final MutableDataFlowInfoForArguments dataFlowInfoForArguments;
@@ -213,6 +214,9 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
}
}
typeArguments = typeArguments.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> substitutor.safeSubstitute(e.getValue(), e.getKey().getVariance())));
if (dispatchReceiver instanceof ExpressionReceiver) {
dispatchReceiver = dispatchReceiver.replaceType(substitutor.safeSubstitute(dispatchReceiver.getType(), Variance.IN_VARIANCE));
}