refactoring: added hasOnlyErrorsFromPosition(ConstraintPosition)
to use it for errors from completer as well
This commit is contained in:
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.TraceUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.CallResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace;
|
||||
@@ -128,7 +129,7 @@ public class CallResolverUtil {
|
||||
|
||||
// Expected type mismatch was reported before as 'TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH'
|
||||
ConstraintSystem constraintSystem = callToComplete.getConstraintSystem();
|
||||
if (constraintSystem != null && constraintSystem.getStatus().hasOnlyExpectedTypeMismatch()) return false;
|
||||
if (constraintSystem != null && constraintSystem.getStatus().hasOnlyErrorsFromPosition(ConstraintPosition.EXPECTED_TYPE_POSITION)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -270,14 +270,13 @@ public class CandidateResolver {
|
||||
BindingContext.CONSTRAINT_SYSTEM_COMPLETER, context.call.getCalleeExpression());
|
||||
if (constraintSystemCompleter == null) return;
|
||||
|
||||
ConstraintSystemImpl backup = (ConstraintSystemImpl) constraintSystem.copy();
|
||||
ConstraintSystem copy = constraintSystem.copy();
|
||||
|
||||
constraintSystemCompleter.completeConstraintSystem(copy, resolvedCall);
|
||||
|
||||
//todo improve error reporting with errors in constraints from completer
|
||||
constraintSystemCompleter.completeConstraintSystem(constraintSystem, resolvedCall);
|
||||
if (constraintSystem.getStatus().hasTypeConstructorMismatchAt(ConstraintPosition.FROM_COMPLETER) ||
|
||||
(constraintSystem.getStatus().hasContradiction() && !backup.getStatus().hasContradiction())) {
|
||||
|
||||
resolvedCall.setConstraintSystem(backup);
|
||||
if (!copy.getStatus().hasOnlyErrorsFromPosition(ConstraintPosition.FROM_COMPLETER)) {
|
||||
resolvedCall.setConstraintSystem(copy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,8 +294,7 @@ public class CandidateResolver {
|
||||
|
||||
copy.addSupertypeConstraint(KotlinBuiltIns.getInstance().getUnitType(), returnType, ConstraintPosition.EXPECTED_TYPE_POSITION);
|
||||
if (copy.getStatus().isSuccessful()) {
|
||||
constraintSystem = copy;
|
||||
resolvedCall.setConstraintSystem(constraintSystem);
|
||||
resolvedCall.setConstraintSystem(copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -220,7 +220,7 @@ public class TracingStrategyImpl implements TracingStrategy {
|
||||
// (it's useful, when the arguments, e.g. lambdas or calls are incomplete)
|
||||
return;
|
||||
}
|
||||
if (status.hasOnlyExpectedTypeMismatch()) {
|
||||
if (status.hasOnlyErrorsFromPosition(ConstraintPosition.EXPECTED_TYPE_POSITION)) {
|
||||
JetType declaredReturnType = data.descriptor.getReturnType();
|
||||
if (declaredReturnType == null) return;
|
||||
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemStatus;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData;
|
||||
@@ -344,7 +345,7 @@ public class ControlStructureTypingUtils {
|
||||
if (status.hasErrorInConstrainingTypes()) {
|
||||
return;
|
||||
}
|
||||
if (status.hasOnlyExpectedTypeMismatch() || status.hasConflictingConstraints()) {
|
||||
if (status.hasOnlyErrorsFromPosition(ConstraintPosition.EXPECTED_TYPE_POSITION) || status.hasConflictingConstraints()) {
|
||||
JetExpression expression = call.getCalleeExpression();
|
||||
if (expression != null) {
|
||||
expression.accept(checkTypeVisitor, new CheckTypeContext(trace, data.expectedType));
|
||||
|
||||
@@ -4,6 +4,8 @@ open class A {
|
||||
val B.w: Int by <!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>MyProperty<!>()
|
||||
}
|
||||
|
||||
val B.r: Int by <!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>MyProperty<!>()
|
||||
|
||||
val A.e: Int by MyProperty()
|
||||
|
||||
class B {
|
||||
|
||||
Reference in New Issue
Block a user