refactoring: register type variable together
not one by one
This commit is contained in:
@@ -562,10 +562,11 @@ public class CandidateResolver {
|
||||
// Thus, we replace the parameters of our descriptor with fresh objects (perform alpha-conversion)
|
||||
CallableDescriptor candidateWithFreshVariables = FunctionDescriptorUtil.alphaConvertTypeParameters(candidate);
|
||||
|
||||
|
||||
Map<TypeParameterDescriptor, Variance> typeVariables = Maps.newLinkedHashMap();
|
||||
for (TypeParameterDescriptor typeParameterDescriptor : candidateWithFreshVariables.getTypeParameters()) {
|
||||
constraintSystem.registerTypeVariable(typeParameterDescriptor, Variance.INVARIANT); // TODO: variance of the occurrences
|
||||
typeVariables.put(typeParameterDescriptor, Variance.INVARIANT); // TODO: variance of the occurrences
|
||||
}
|
||||
constraintSystem.registerTypeVariables(typeVariables);
|
||||
|
||||
TypeSubstitutor substituteDontCare = ConstraintsUtil
|
||||
.makeConstantSubstitutor(candidateWithFreshVariables.getTypeParameters(), DONT_CARE);
|
||||
|
||||
+4
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.lang.types.expressions;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -301,11 +302,13 @@ public class ExpressionTypingUtils {
|
||||
Set<Name> typeNamesInReceiver = collectUsedTypeNames(receiverParameter.getType());
|
||||
|
||||
ConstraintSystem constraintSystem = new ConstraintSystemImpl();
|
||||
Map<TypeParameterDescriptor, Variance> typeVariables = Maps.newLinkedHashMap();
|
||||
for (TypeParameterDescriptor typeParameterDescriptor : callableDescriptor.getTypeParameters()) {
|
||||
if (typeNamesInReceiver.contains(typeParameterDescriptor.getName())) {
|
||||
constraintSystem.registerTypeVariable(typeParameterDescriptor, Variance.INVARIANT);
|
||||
typeVariables.put(typeParameterDescriptor, Variance.INVARIANT);
|
||||
}
|
||||
}
|
||||
constraintSystem.registerTypeVariables(typeVariables);
|
||||
|
||||
constraintSystem.addSubtypeConstraint(receiverType, receiverParameter.getType(), ConstraintPosition.RECEIVER_POSITION);
|
||||
return constraintSystem.getStatus().isSuccessful() && ConstraintsUtil.checkBoundsAreSatisfied(constraintSystem, true);
|
||||
|
||||
Reference in New Issue
Block a user