interface ResolvedCallWithTrace added
This commit is contained in:
+9
-9
@@ -27,42 +27,42 @@ import java.util.Collections;
|
||||
*/
|
||||
/*package*/ class OverloadResolutionResultsImpl<D extends CallableDescriptor> implements OverloadResolutionResults<D> {
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> success(@NotNull ResolvedCallImpl<D> descriptor) {
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> success(@NotNull ResolvedCallWithTrace<D> descriptor) {
|
||||
return new OverloadResolutionResultsImpl<D>(Code.SUCCESS, Collections.singleton(descriptor));
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> nameNotFound() {
|
||||
return new OverloadResolutionResultsImpl<D>(Code.NAME_NOT_FOUND, Collections.<ResolvedCallImpl<D>>emptyList());
|
||||
return new OverloadResolutionResultsImpl<D>(Code.NAME_NOT_FOUND, Collections.<ResolvedCallWithTrace<D>>emptyList());
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> singleFailedCandidate(ResolvedCallImpl<D> candidate) {
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> singleFailedCandidate(ResolvedCallWithTrace<D> candidate) {
|
||||
return new OverloadResolutionResultsImpl<D>(Code.SINGLE_CANDIDATE_ARGUMENT_MISMATCH, Collections.singleton(candidate));
|
||||
}
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> manyFailedCandidates(Collection<ResolvedCallImpl<D>> failedCandidates) {
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> manyFailedCandidates(Collection<ResolvedCallWithTrace<D>> failedCandidates) {
|
||||
return new OverloadResolutionResultsImpl<D>(Code.MANY_FAILED_CANDIDATES, failedCandidates);
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> ambiguity(Collection<ResolvedCallImpl<D>> descriptors) {
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> ambiguity(Collection<ResolvedCallWithTrace<D>> descriptors) {
|
||||
return new OverloadResolutionResultsImpl<D>(Code.AMBIGUITY, descriptors);
|
||||
}
|
||||
|
||||
private final Collection<ResolvedCallImpl<D>> results;
|
||||
private final Collection<ResolvedCallWithTrace<D>> results;
|
||||
private final Code resultCode;
|
||||
|
||||
private OverloadResolutionResultsImpl(@NotNull Code resultCode, @NotNull Collection<ResolvedCallImpl<D>> results) {
|
||||
private OverloadResolutionResultsImpl(@NotNull Code resultCode, @NotNull Collection<ResolvedCallWithTrace<D>> results) {
|
||||
this.results = results;
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<ResolvedCallImpl<D>> getResultingCalls() {
|
||||
public Collection<ResolvedCallWithTrace<D>> getResultingCalls() {
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ResolvedCallImpl<D> getResultingCall() {
|
||||
public ResolvedCallWithTrace<D> getResultingCall() {
|
||||
assert isSingleResult();
|
||||
return results.iterator().next();
|
||||
}
|
||||
|
||||
+3
-3
@@ -30,9 +30,9 @@ import java.util.Collection;
|
||||
public class OverloadResolutionResultsUtil {
|
||||
@NotNull
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> ambiguity(OverloadResolutionResults<D> results1, OverloadResolutionResults<D> results2) {
|
||||
Collection<ResolvedCallImpl<D>> resultingCalls = Lists.newArrayList();
|
||||
resultingCalls.addAll((Collection<ResolvedCallImpl<D>>) results1.getResultingCalls());
|
||||
resultingCalls.addAll((Collection<ResolvedCallImpl<D>>) results2.getResultingCalls());
|
||||
Collection<ResolvedCallWithTrace<D>> resultingCalls = Lists.newArrayList();
|
||||
resultingCalls.addAll((Collection<ResolvedCallWithTrace<D>>) results1.getResultingCalls());
|
||||
resultingCalls.addAll((Collection<ResolvedCallWithTrace<D>>) results2.getResultingCalls());
|
||||
return OverloadResolutionResultsImpl.ambiguity(resultingCalls);
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -39,23 +39,23 @@ import java.util.Set;
|
||||
public class OverloadingConflictResolver {
|
||||
|
||||
@Nullable
|
||||
public <D extends CallableDescriptor> ResolvedCallImpl<D> findMaximallySpecific(Set<ResolvedCallImpl<D>> candidates, boolean discriminateGenericDescriptors) {
|
||||
public <D extends CallableDescriptor> ResolvedCallWithTrace<D> findMaximallySpecific(Set<ResolvedCallWithTrace<D>> candidates, boolean discriminateGenericDescriptors) {
|
||||
// Different autocasts may lead to the same candidate descriptor wrapped into different ResolvedCallImpl objects
|
||||
Set<ResolvedCallImpl<D>> maximallySpecific = new THashSet<ResolvedCallImpl<D>>(new TObjectHashingStrategy<ResolvedCallImpl<D>>() {
|
||||
Set<ResolvedCallWithTrace<D>> maximallySpecific = new THashSet<ResolvedCallWithTrace<D>>(new TObjectHashingStrategy<ResolvedCallWithTrace<D>>() {
|
||||
@Override
|
||||
public boolean equals(ResolvedCallImpl<D> o1, ResolvedCallImpl<D> o2) {
|
||||
public boolean equals(ResolvedCallWithTrace<D> o1, ResolvedCallWithTrace<D> o2) {
|
||||
return o1 == null ? o2 == null : o1.getResultingDescriptor().equals(o2.getResultingDescriptor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int computeHashCode(ResolvedCallImpl<D> object) {
|
||||
public int computeHashCode(ResolvedCallWithTrace<D> object) {
|
||||
return object == null ? 0 : object.getResultingDescriptor().hashCode();
|
||||
}
|
||||
});
|
||||
meLoop:
|
||||
for (ResolvedCallImpl<D> candidateCall : candidates) {
|
||||
for (ResolvedCallWithTrace<D> candidateCall : candidates) {
|
||||
D me = candidateCall.getResultingDescriptor();
|
||||
for (ResolvedCallImpl<D> otherCall : candidates) {
|
||||
for (ResolvedCallWithTrace<D> otherCall : candidates) {
|
||||
D other = otherCall.getResultingDescriptor();
|
||||
if (other == me) continue;
|
||||
if (!moreSpecific(me, other, discriminateGenericDescriptors) || moreSpecific(other, me, discriminateGenericDescriptors)) {
|
||||
@@ -65,7 +65,7 @@ public class OverloadingConflictResolver {
|
||||
maximallySpecific.add(candidateCall);
|
||||
}
|
||||
if (maximallySpecific.size() == 1) {
|
||||
ResolvedCallImpl<D> result = maximallySpecific.iterator().next();
|
||||
ResolvedCallWithTrace<D> result = maximallySpecific.iterator().next();
|
||||
result.getTrace().commit();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -28,7 +27,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -37,25 +35,30 @@ import static org.jetbrains.jet.lang.resolve.calls.ResolutionStatus.UNKNOWN_STAT
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedCall<D> {
|
||||
public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedCallWithTrace<D> {
|
||||
|
||||
public static final Function<ResolvedCallImpl<? extends CallableDescriptor>, CallableDescriptor> MAP_TO_CANDIDATE = new Function<ResolvedCallImpl<? extends CallableDescriptor>, CallableDescriptor>() {
|
||||
public static final Function<ResolvedCallWithTrace<? extends CallableDescriptor>, CallableDescriptor> MAP_TO_CANDIDATE = new Function<ResolvedCallWithTrace<? extends CallableDescriptor>, CallableDescriptor>() {
|
||||
@Override
|
||||
public CallableDescriptor fun(ResolvedCallImpl<? extends CallableDescriptor> resolvedCall) {
|
||||
public CallableDescriptor fun(ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall) {
|
||||
return resolvedCall.getCandidateDescriptor();
|
||||
}
|
||||
};
|
||||
|
||||
public static final Function<ResolvedCallImpl<? extends CallableDescriptor>, CallableDescriptor> MAP_TO_RESULT = new Function<ResolvedCallImpl<? extends CallableDescriptor>, CallableDescriptor>() {
|
||||
public static final Function<ResolvedCallWithTrace<? extends CallableDescriptor>, CallableDescriptor> MAP_TO_RESULT = new Function<ResolvedCallWithTrace<? extends CallableDescriptor>, CallableDescriptor>() {
|
||||
@Override
|
||||
public CallableDescriptor fun(ResolvedCallImpl<? extends CallableDescriptor> resolvedCall) {
|
||||
public CallableDescriptor fun(ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall) {
|
||||
return resolvedCall.getResultingDescriptor();
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
public static <D extends CallableDescriptor> ResolvedCallImpl<D> create(@NotNull ResolutionCandidate<D> candidate) {
|
||||
return new ResolvedCallImpl<D>(candidate.getDescriptor(), candidate.getThisObject(), candidate.getReceiverArgument());
|
||||
public static <D extends CallableDescriptor> ResolvedCallImpl<D> create(@NotNull ResolutionCandidate<D> candidate, @NotNull TemporaryBindingTrace trace) {
|
||||
return create(candidate.getDescriptor(), candidate.getThisObject(), candidate.getReceiverArgument(), trace);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <D extends CallableDescriptor> ResolvedCallImpl<D> create(@NotNull D descriptor, @NotNull ReceiverDescriptor thisObject, @NotNull ReceiverDescriptor receiverArgument, @NotNull TemporaryBindingTrace trace) {
|
||||
return new ResolvedCallImpl<D>(descriptor, thisObject, receiverArgument, trace);
|
||||
}
|
||||
|
||||
private final D candidateDescriptor;
|
||||
@@ -70,10 +73,11 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedC
|
||||
private TemporaryBindingTrace trace;
|
||||
private ResolutionStatus status = UNKNOWN_STATUS;
|
||||
|
||||
private ResolvedCallImpl(@NotNull D candidateDescriptor, @NotNull ReceiverDescriptor thisObject, @NotNull ReceiverDescriptor receiverArgument) {
|
||||
private ResolvedCallImpl(@NotNull D candidateDescriptor, @NotNull ReceiverDescriptor thisObject, @NotNull ReceiverDescriptor receiverArgument, @NotNull TemporaryBindingTrace trace) {
|
||||
this.candidateDescriptor = candidateDescriptor;
|
||||
this.thisObject = thisObject;
|
||||
this.receiverArgument = receiverArgument;
|
||||
this.trace = trace;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -90,10 +94,6 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedC
|
||||
return trace;
|
||||
}
|
||||
|
||||
public void setTrace(@NotNull TemporaryBindingTrace trace) {
|
||||
this.trace = trace;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public D getCandidateDescriptor() {
|
||||
|
||||
+6
-10
@@ -18,21 +18,17 @@ package org.jetbrains.jet.lang.resolve.calls;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public interface MemberPrioritizer<D extends CallableDescriptor> {
|
||||
@NotNull
|
||||
Collection<D> getNonExtensionsByName(JetScope scope, String name);
|
||||
public interface ResolvedCallWithTrace<D extends CallableDescriptor> extends ResolvedCall<D> {
|
||||
|
||||
@NotNull
|
||||
Collection<D> getMembersByName(@NotNull JetType receiver, String name);
|
||||
ResolutionStatus getStatus();
|
||||
|
||||
@NotNull
|
||||
Collection<D> getExtensionsByName(JetScope scope, String name);
|
||||
boolean isDirty();
|
||||
|
||||
TemporaryBindingTrace getTrace();
|
||||
}
|
||||
@@ -34,14 +34,15 @@ import java.util.List;
|
||||
*/
|
||||
/*package*/ interface TracingStrategy {
|
||||
TracingStrategy EMPTY = new TracingStrategy() {
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCallImpl<D> resolvedCall) {}
|
||||
public <D extends CallableDescriptor> void bindResolvedCall(@NotNull BindingTrace trace, @NotNull ResolvedCallWithTrace<D> resolvedCall) {}
|
||||
|
||||
@Override
|
||||
public void unresolvedReference(@NotNull BindingTrace trace) {}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCallImpl<D>> candidates) {}
|
||||
public <D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCallWithTrace<D>> candidates) {}
|
||||
|
||||
@Override
|
||||
public void missingReceiver(@NotNull BindingTrace trace, @NotNull ReceiverDescriptor expectedReceiver) {}
|
||||
@@ -59,10 +60,10 @@ import java.util.List;
|
||||
public void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount) {}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Collection<ResolvedCallImpl<D>> descriptors) {}
|
||||
public <D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Collection<ResolvedCallWithTrace<D>> descriptors) {}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void noneApplicable(@NotNull BindingTrace trace, @NotNull Collection<ResolvedCallImpl<D>> descriptors) {}
|
||||
public <D extends CallableDescriptor> void noneApplicable(@NotNull BindingTrace trace, @NotNull Collection<ResolvedCallWithTrace<D>> descriptors) {}
|
||||
|
||||
@Override
|
||||
public void instantiationOfAbstractClass(@NotNull BindingTrace trace) {}
|
||||
@@ -83,11 +84,11 @@ import java.util.List;
|
||||
public void invisibleMember(@NotNull BindingTrace trace, @NotNull DeclarationDescriptor descriptor) {}
|
||||
};
|
||||
|
||||
<D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCallImpl<D> resolvedCall);
|
||||
<D extends CallableDescriptor> void bindResolvedCall(@NotNull BindingTrace trace, @NotNull ResolvedCallWithTrace<D> resolvedCall);
|
||||
|
||||
void unresolvedReference(@NotNull BindingTrace trace);
|
||||
|
||||
<D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCallImpl<D>> candidates);
|
||||
<D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCallWithTrace<D>> candidates);
|
||||
|
||||
void missingReceiver(@NotNull BindingTrace trace, @NotNull ReceiverDescriptor expectedReceiver);
|
||||
|
||||
@@ -99,9 +100,9 @@ import java.util.List;
|
||||
|
||||
void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount);
|
||||
|
||||
<D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Collection<ResolvedCallImpl<D>> descriptors);
|
||||
<D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Collection<ResolvedCallWithTrace<D>> descriptors);
|
||||
|
||||
<D extends CallableDescriptor> void noneApplicable(@NotNull BindingTrace trace, @NotNull Collection<ResolvedCallImpl<D>> descriptors);
|
||||
<D extends CallableDescriptor> void noneApplicable(@NotNull BindingTrace trace, @NotNull Collection<ResolvedCallWithTrace<D>> descriptors);
|
||||
|
||||
void instantiationOfAbstractClass(@NotNull BindingTrace trace);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user