ResolvedCallImpl.copy moved to Util
This commit is contained in:
@@ -320,7 +320,7 @@ public class CallResolver {
|
||||
Set<ResolvedCallWithTrace<D>> failed = Sets.newLinkedHashSet();
|
||||
for (ResolvedCall<? extends D> call : resultsWithIncompleteTypeInference.getResultingCalls()) {
|
||||
if (!(call instanceof ResolvedCallImpl)) continue;
|
||||
ResolvedCallImpl<D> resolvedCall = ((ResolvedCallImpl<D>) call).copy(context);
|
||||
ResolvedCallImpl<D> resolvedCall = CallResolverUtil.copy((ResolvedCallImpl<D>) call, context);
|
||||
if (!resolvedCall.hasUnknownTypeParameters()) {
|
||||
if (resolvedCall.getStatus().isSuccess()) {
|
||||
successful.add(resolvedCall);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CallResolverUtil {
|
||||
|
||||
public static <D extends CallableDescriptor> ResolvedCallImpl<D> copy(@NotNull ResolvedCallImpl<D> call, @NotNull ResolutionContext context) {
|
||||
ResolutionCandidate<D> candidate = ResolutionCandidate.create(call.getCandidateDescriptor(), call.getThisObject(),
|
||||
call.getReceiverArgument(), call.getExplicitReceiverKind(),
|
||||
call.isSafeCall());
|
||||
|
||||
TemporaryBindingTrace trace = TemporaryBindingTrace.create(context.trace, call.getTrace().toString() + "(copy)");
|
||||
ResolvedCallImpl<D> copy = ResolvedCallImpl.create(candidate, trace);
|
||||
|
||||
call.getTrace().addAllMyDataTo(trace);
|
||||
trace.record(BindingContext.RESOLVED_CALL, context.call.getCalleeExpression(), copy);
|
||||
|
||||
if (call.isDirty()) {
|
||||
copy.argumentHasNoType();
|
||||
}
|
||||
copy.setHasUnknownTypeParameters(call.hasUnknownTypeParameters());
|
||||
ConstraintSystem constraintSystem = call.getConstraintSystem();
|
||||
if (constraintSystem != null) {
|
||||
copy.setConstraintSystem(constraintSystem.copy());
|
||||
}
|
||||
for (Map.Entry<TypeParameterDescriptor, JetType> entry : call.getTypeArguments().entrySet()) {
|
||||
copy.recordTypeArgument(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : call.getValueArguments().entrySet()) {
|
||||
copy.recordValueArgument(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedC
|
||||
|
||||
@NotNull
|
||||
public static <D extends CallableDescriptor> ResolvedCallImpl<D> create(@NotNull ResolutionCandidate<D> candidate, @NotNull DelegatingBindingTrace trace) {
|
||||
return new ResolvedCallImpl<D>(candidate.getDescriptor(), candidate.getThisObject(), candidate.getReceiverArgument(), candidate.getExplicitReceiverKind(), candidate.isSafeCall(), trace);
|
||||
return new ResolvedCallImpl<D>(candidate, trace);
|
||||
}
|
||||
|
||||
private final D candidateDescriptor;
|
||||
@@ -76,19 +76,12 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedC
|
||||
private boolean hasUnknownTypeParameters = false;
|
||||
private ConstraintSystem constraintSystem = null;
|
||||
|
||||
private ResolvedCallImpl(
|
||||
@NotNull D candidateDescriptor,
|
||||
@NotNull ReceiverDescriptor thisObject,
|
||||
@NotNull ReceiverDescriptor receiverArgument,
|
||||
@NotNull ExplicitReceiverKind explicitReceiverKind,
|
||||
boolean isSafeCall,
|
||||
@NotNull DelegatingBindingTrace trace
|
||||
) {
|
||||
this.candidateDescriptor = candidateDescriptor;
|
||||
this.thisObject = thisObject;
|
||||
this.receiverArgument = receiverArgument;
|
||||
this.explicitReceiverKind = explicitReceiverKind;
|
||||
this.isSafeCall = isSafeCall;
|
||||
private ResolvedCallImpl(@NotNull ResolutionCandidate<D> candidate, @NotNull DelegatingBindingTrace trace) {
|
||||
this.candidateDescriptor = candidate.getDescriptor();
|
||||
this.thisObject = candidate.getThisObject();
|
||||
this.receiverArgument = candidate.getReceiverArgument();
|
||||
this.explicitReceiverKind = candidate.getExplicitReceiverKind();
|
||||
this.isSafeCall = candidate.isSafeCall();
|
||||
this.trace = trace;
|
||||
}
|
||||
|
||||
@@ -237,23 +230,4 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedC
|
||||
public boolean isSafeCall() {
|
||||
return isSafeCall;
|
||||
}
|
||||
|
||||
public ResolvedCallImpl<D> copy(@NotNull ResolutionContext context) {
|
||||
ResolvedCallImpl<D> resolvedCall = new ResolvedCallImpl<D>(
|
||||
candidateDescriptor, thisObject, receiverArgument, explicitReceiverKind, isSafeCall,
|
||||
TemporaryBindingTrace.create(context.trace, this.trace + "(copy)"));
|
||||
this.trace.addAllMyDataTo(resolvedCall.trace);
|
||||
resolvedCall.trace.record(BindingContext.RESOLVED_CALL, context.call.getCalleeExpression(), resolvedCall);
|
||||
|
||||
resolvedCall.someArgumentHasNoType = this.someArgumentHasNoType;
|
||||
resolvedCall.hasUnknownTypeParameters = this.hasUnknownTypeParameters;
|
||||
if (constraintSystem != null) {
|
||||
resolvedCall.constraintSystem = this.constraintSystem.copy();
|
||||
}
|
||||
resolvedCall.typeArguments.putAll(this.typeArguments);
|
||||
resolvedCall.valueArguments.putAll(this.valueArguments);
|
||||
resolvedCall.autoCasts.putAll(this.autoCasts);
|
||||
assert this.resultingDescriptor == null;
|
||||
return resolvedCall;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user