refactoring: register type variable together

not one by one
This commit is contained in:
Svetlana Isakova
2013-09-25 20:50:52 +04:00
parent de85d3df72
commit c150c22473
5 changed files with 17 additions and 11 deletions
@@ -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);
@@ -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);