refactoring: register type variable together
not one by one
This commit is contained in:
+3
-3
@@ -23,15 +23,15 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ConstraintSystem {
|
||||
|
||||
/**
|
||||
* Registers a variable in a constraint system.
|
||||
* Registers variables in a constraint system.
|
||||
*/
|
||||
void registerTypeVariable(@NotNull TypeParameterDescriptor typeVariable, @NotNull Variance positionVariance);
|
||||
void registerTypeVariables(@NotNull Map<TypeParameterDescriptor, Variance> typeVariables);
|
||||
|
||||
/**
|
||||
* Returns a set of all registered type variables.
|
||||
|
||||
+6
-2
@@ -163,8 +163,12 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTypeVariable(@NotNull TypeParameterDescriptor typeVariable, @NotNull Variance positionVariance) {
|
||||
typeParameterConstraints.put(typeVariable, new TypeConstraintsImpl(positionVariance));
|
||||
public void registerTypeVariables(@NotNull Map<TypeParameterDescriptor, Variance> typeVariables) {
|
||||
for (Map.Entry<TypeParameterDescriptor, Variance> entry : typeVariables.entrySet()) {
|
||||
TypeParameterDescriptor typeVariable = entry.getKey();
|
||||
Variance positionVariance = entry.getValue();
|
||||
typeParameterConstraints.put(typeVariable, new TypeConstraintsImpl(positionVariance));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -261,9 +261,7 @@ public class TypeUtils {
|
||||
processAllTypeParameters(withParameters, Variance.INVARIANT, processor);
|
||||
processAllTypeParameters(expected, Variance.INVARIANT, processor);
|
||||
ConstraintSystemImpl constraintSystem = new ConstraintSystemImpl();
|
||||
for (Map.Entry<TypeParameterDescriptor, Variance> entry : parameters.entrySet()) {
|
||||
constraintSystem.registerTypeVariable(entry.getKey(), entry.getValue());
|
||||
}
|
||||
constraintSystem.registerTypeVariables(parameters);
|
||||
constraintSystem.addSubtypeConstraint(withParameters, expected, ConstraintPosition.SPECIAL);
|
||||
|
||||
return constraintSystem.getStatus().isSuccessful();
|
||||
|
||||
Reference in New Issue
Block a user