map changed to function
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -689,7 +690,7 @@ public class CallResolver {
|
||||
|
||||
private <D extends CallableDescriptor, F extends D> ResolutionStatus inferTypeArguments(CallResolutionContext<D, F> context) {
|
||||
ResolvedCallImpl<D> candidateCall = context.candidateCall;
|
||||
D candidate = candidateCall.getCandidateDescriptor();
|
||||
final D candidate = candidateCall.getCandidateDescriptor();
|
||||
|
||||
ResolutionDebugInfo.Data debugInfo = context.trace.get(ResolutionDebugInfo.RESOLUTION_DEBUG_INFO, context.call.getCallElement());
|
||||
|
||||
@@ -741,12 +742,13 @@ public class CallResolver {
|
||||
ConstraintPosition.RECEIVER_POSITION);
|
||||
}
|
||||
|
||||
Map<TypeParameterDescriptor, TypeParameterDescriptor> typeVariablesMap = Maps.newLinkedHashMap();
|
||||
for (TypeParameterDescriptor typeParameterDescriptor : candidate.getTypeParameters()) {
|
||||
typeVariablesMap.put(candidateWithFreshVariables.getTypeParameters().get(typeParameterDescriptor.getIndex()),
|
||||
typeParameterDescriptor);
|
||||
}
|
||||
ConstraintSystem constraintBuilderWithRightTypeParameters = constraintsSystem.replaceTypeVariables(typeVariablesMap);
|
||||
ConstraintSystem constraintBuilderWithRightTypeParameters = constraintsSystem.replaceTypeVariables(new Function<TypeParameterDescriptor, TypeParameterDescriptor>() {
|
||||
@Override
|
||||
public TypeParameterDescriptor apply(@Nullable TypeParameterDescriptor typeParameterDescriptor) {
|
||||
assert typeParameterDescriptor != null;
|
||||
return candidate.getTypeParameters().get(typeParameterDescriptor.getIndex());
|
||||
}
|
||||
});
|
||||
candidateCall.setConstraintSystem(constraintBuilderWithRightTypeParameters);
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.inference;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -105,13 +106,13 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ConstraintSystemImpl replaceTypeVariables(@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptor> typeVariablesMap) {
|
||||
public ConstraintSystem replaceTypeVariables(@NotNull Function<TypeParameterDescriptor, TypeParameterDescriptor> typeVariablesMap) {
|
||||
ConstraintSystemImpl newConstraintSystem = new ConstraintSystemImpl();
|
||||
for (Map.Entry<TypeParameterDescriptor, TypeConstraintsImpl> entry : typeParameterConstraints.entrySet()) {
|
||||
TypeParameterDescriptor typeParameter = entry.getKey();
|
||||
TypeConstraintsImpl typeConstraints = entry.getValue();
|
||||
|
||||
TypeParameterDescriptor newTypeParameter = typeVariablesMap.get(typeParameter);
|
||||
TypeParameterDescriptor newTypeParameter = typeVariablesMap.apply(typeParameter);
|
||||
assert newTypeParameter != null;
|
||||
newConstraintSystem.typeParameterConstraints.put(newTypeParameter, typeConstraints);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user