store 'hasInferredReturnType' in resolved call
instead of trying to compute it later
This commit is contained in:
@@ -104,11 +104,10 @@ public class CallResolverUtil {
|
||||
return new JetTypeImpl(type.getAnnotations(), type.getConstructor(), type.isNullable(), newArguments, type.getMemberScope());
|
||||
}
|
||||
|
||||
private static boolean hasReturnTypeDependentOnNotInferredParams(@NotNull ResolvedCallImpl<?> callToComplete) {
|
||||
ConstraintSystem constraintSystem = callToComplete.getConstraintSystem();
|
||||
if (constraintSystem == null) return false;
|
||||
|
||||
CallableDescriptor candidateDescriptor = callToComplete.getCandidateDescriptor();
|
||||
private static boolean hasReturnTypeDependentOnNotInferredParams(
|
||||
@NotNull CallableDescriptor candidateDescriptor,
|
||||
@NotNull ConstraintSystem constraintSystem
|
||||
) {
|
||||
JetType returnType = candidateDescriptor.getReturnType();
|
||||
if (returnType == null) return false;
|
||||
|
||||
@@ -123,13 +122,14 @@ public class CallResolverUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasInferredReturnType(ResolvedCallWithTrace<?> call) {
|
||||
ResolvedCallImpl<?> callToComplete = call.getCallToCompleteTypeArgumentInference();
|
||||
if (hasReturnTypeDependentOnNotInferredParams(callToComplete)) return false;
|
||||
public static boolean hasInferredReturnType(
|
||||
@NotNull CallableDescriptor candidateDescriptor,
|
||||
@NotNull ConstraintSystem constraintSystem
|
||||
) {
|
||||
if (hasReturnTypeDependentOnNotInferredParams(candidateDescriptor, constraintSystem)) return false;
|
||||
|
||||
// Expected type mismatch was reported before as 'TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH'
|
||||
ConstraintSystem constraintSystem = callToComplete.getConstraintSystem();
|
||||
if (constraintSystem != null && constraintSystem.getStatus().hasOnlyErrorsFromPosition(ConstraintPosition.EXPECTED_TYPE_POSITION)) return false;
|
||||
if (constraintSystem.getStatus().hasOnlyErrorsFromPosition(ConstraintPosition.EXPECTED_TYPE_POSITION)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ public class CandidateResolver {
|
||||
|
||||
context.tracing.typeInferenceFailed(context.trace, errorData);
|
||||
resolvedCall.addStatus(ResolutionStatus.OTHER_ERROR);
|
||||
if (!CallResolverUtil.hasInferredReturnType(resolvedCall)) return null;
|
||||
if (!resolvedCall.hasInferredReturnType()) return null;
|
||||
return resolvedCall.getResultingDescriptor().getReturnType();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus;
|
||||
@@ -86,6 +87,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedC
|
||||
private ResolutionStatus status = UNKNOWN_STATUS;
|
||||
private boolean hasUnknownTypeParameters = false;
|
||||
private ConstraintSystem constraintSystem = null;
|
||||
private boolean hasInferredReturnType;
|
||||
private boolean cleaned = false;
|
||||
|
||||
private ResolvedCallImpl(
|
||||
@@ -137,12 +139,19 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedC
|
||||
|
||||
@Override
|
||||
public void cleanInternalData() {
|
||||
if (!cleaned) {
|
||||
hasInferredReturnType = CallResolverUtil.hasInferredReturnType(candidateDescriptor, constraintSystem);
|
||||
}
|
||||
trace = null;
|
||||
constraintSystem = null;
|
||||
tracing = null;
|
||||
cleaned = true;
|
||||
}
|
||||
|
||||
public boolean hasInferredReturnType() {
|
||||
return hasInferredReturnType;
|
||||
}
|
||||
|
||||
private void checkCallIsUnfinished(String elementName) {
|
||||
if (cleaned) throw new IllegalStateException(elementName + " is erased after resolution completion.");
|
||||
}
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class OverloadResolutionResultsUtil {
|
||||
@NotNull ContextDependency contextDependency
|
||||
) {
|
||||
if (results.isSingleResult() && contextDependency == ContextDependency.INDEPENDENT) {
|
||||
if (!CallResolverUtil.hasInferredReturnType(results.getResultingCall())) {
|
||||
if (!results.getResultingCall().getCallToCompleteTypeArgumentInference().hasInferredReturnType()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user