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