refactoring: removed logic of rendering 'expected type mismatch' error from constraint system
This commit is contained in:
+4
-4
@@ -23,9 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
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;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -226,7 +224,9 @@ public class TracingStrategyImpl implements TracingStrategy {
|
||||
JetType declaredReturnType = data.descriptor.getReturnType();
|
||||
if (declaredReturnType == null) return;
|
||||
|
||||
JetType substitutedReturnType = constraintSystem.getResultingSubstitutor().substitute(declaredReturnType, Variance.INVARIANT);
|
||||
ConstraintSystem systemWithoutExpectedTypeConstraint =
|
||||
((ConstraintSystemImpl) constraintSystem).filterConstraintsOut(ConstraintPosition.EXPECTED_TYPE_POSITION);
|
||||
JetType substitutedReturnType = systemWithoutExpectedTypeConstraint.getResultingSubstitutor().substitute(declaredReturnType, Variance.INVARIANT);
|
||||
assert substitutedReturnType != null; //todo
|
||||
|
||||
assert !noExpectedType(data.expectedType) : "Expected type doesn't exist, but there is an expected type mismatch error";
|
||||
|
||||
-3
@@ -486,9 +486,6 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
||||
@NotNull
|
||||
@Override
|
||||
public TypeSubstitutor getResultingSubstitutor() {
|
||||
if (getStatus().hasOnlyExpectedTypeMismatch()) {
|
||||
return filterConstraintsOut(EXPECTED_TYPE_POSITION).getResultingSubstitutor();
|
||||
}
|
||||
return resultingSubstitutor;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package s
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun test(set: Set<Int>) {
|
||||
val s: String = id(1)
|
||||
|
||||
val l: List<Int> = id(set)
|
||||
|
||||
val ss: Set<String> = id(set)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<!-- typeInferenceExpectedTypeMismatch1 -->
|
||||
<html>
|
||||
Type inference failed. Expected type mismatch: <table>
|
||||
<tr>
|
||||
<td>
|
||||
required: </td>
|
||||
<td>
|
||||
<b>
|
||||
jet.String</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
found: </td>
|
||||
<td>
|
||||
<font color=red>
|
||||
<b>
|
||||
jet.Int</b>
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</html>
|
||||
@@ -0,0 +1,23 @@
|
||||
<!-- typeInferenceExpectedTypeMismatch2 -->
|
||||
<html>
|
||||
Type inference failed. Expected type mismatch: <table>
|
||||
<tr>
|
||||
<td>
|
||||
required: </td>
|
||||
<td>
|
||||
<b>
|
||||
jet.List<jet.Int></b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
found: </td>
|
||||
<td>
|
||||
<font color=red>
|
||||
<b>
|
||||
jet.Set<jet.Int></b>
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</html>
|
||||
@@ -0,0 +1,23 @@
|
||||
<!-- typeInferenceExpectedTypeMismatch3 -->
|
||||
<html>
|
||||
Type inference failed. Expected type mismatch: <table>
|
||||
<tr>
|
||||
<td>
|
||||
required: </td>
|
||||
<td>
|
||||
<b>
|
||||
jet.Set<jet.String></b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
found: </td>
|
||||
<td>
|
||||
<font color=red>
|
||||
<b>
|
||||
jet.Set<jet.Int></b>
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</html>
|
||||
@@ -118,4 +118,8 @@ public class DiagnosticMessageTest extends JetLiteFixture {
|
||||
doTest("numberValueTypes", 4, Errors.TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, Errors.TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH,
|
||||
Errors.TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS);
|
||||
}
|
||||
|
||||
public void testTypeInferenceExpectedTypeMismatch() throws Exception {
|
||||
doTest("typeInferenceExpectedTypeMismatch", 3, Errors.TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user