fixed bug in renderer for violated upper bound error
This commit is contained in:
committed by
Andrey Breslav
parent
c3ff6a2430
commit
4657a4b271
@@ -267,7 +267,8 @@ public class Renderers {
|
|||||||
|
|
||||||
TypeParameterDescriptor typeParameterDescriptor = null;
|
TypeParameterDescriptor typeParameterDescriptor = null;
|
||||||
ConstraintSystemImpl constraintSystem = (ConstraintSystemImpl) inferenceErrorData.constraintSystem;
|
ConstraintSystemImpl constraintSystem = (ConstraintSystemImpl) inferenceErrorData.constraintSystem;
|
||||||
assert constraintSystem.getStatus().hasViolatedUpperBound();
|
ConstraintSystemStatus status = constraintSystem.getStatus();
|
||||||
|
assert status.hasViolatedUpperBound();
|
||||||
|
|
||||||
ConstraintSystem systemWithoutWeakConstraints = constraintSystem.getSystemWithoutWeakConstraints();
|
ConstraintSystem systemWithoutWeakConstraints = constraintSystem.getSystemWithoutWeakConstraints();
|
||||||
for (TypeParameterDescriptor typeParameter : inferenceErrorData.descriptor.getTypeParameters()) {
|
for (TypeParameterDescriptor typeParameter : inferenceErrorData.descriptor.getTypeParameters()) {
|
||||||
@@ -275,6 +276,9 @@ public class Renderers {
|
|||||||
typeParameterDescriptor = typeParameter;
|
typeParameterDescriptor = typeParameter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (typeParameterDescriptor == null && status.hasConflictingConstraints()) {
|
||||||
|
return renderConflictingSubstitutionsInferenceError(inferenceErrorData, result);
|
||||||
|
}
|
||||||
assert typeParameterDescriptor != null : errorMessage;
|
assert typeParameterDescriptor != null : errorMessage;
|
||||||
|
|
||||||
JetType inferredValueForTypeParameter = systemWithoutWeakConstraints.getTypeBounds(typeParameterDescriptor).getValue();
|
JetType inferredValueForTypeParameter = systemWithoutWeakConstraints.getTypeBounds(typeParameterDescriptor).getValue();
|
||||||
|
|||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package g
|
||||||
|
|
||||||
|
import java.util.HashSet
|
||||||
|
fun <T, C: Collection<T>> convert(src: Collection<T>, dest: C): C = throw Exception("$src $dest")
|
||||||
|
|
||||||
|
fun test(l: List<Int>) {
|
||||||
|
//todo should be inferred
|
||||||
|
val r = <!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>convert<!>(l, <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>HashSet<!>())
|
||||||
|
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>r<!>: Int
|
||||||
|
}
|
||||||
@@ -3907,6 +3907,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/inference/upperBounds"), Pattern.compile("^(.+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/inference/upperBounds"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("conflictingSubstitutionsFromUpperBound.kt")
|
||||||
|
public void testConflictingSubstitutionsFromUpperBound() throws Exception {
|
||||||
|
doTest("compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("doNotInferFromBoundsOnly.kt")
|
@TestMetadata("doNotInferFromBoundsOnly.kt")
|
||||||
public void testDoNotInferFromBoundsOnly() throws Exception {
|
public void testDoNotInferFromBoundsOnly() throws Exception {
|
||||||
doTest("compiler/testData/diagnostics/tests/inference/upperBounds/doNotInferFromBoundsOnly.kt");
|
doTest("compiler/testData/diagnostics/tests/inference/upperBounds/doNotInferFromBoundsOnly.kt");
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import java.util.*;
|
|||||||
|
|
||||||
import static org.jetbrains.jet.lang.types.TypeUtils.CANT_INFER_LAMBDA_PARAM_TYPE;
|
import static org.jetbrains.jet.lang.types.TypeUtils.CANT_INFER_LAMBDA_PARAM_TYPE;
|
||||||
import static org.jetbrains.jet.lang.types.TypeUtils.CANT_INFER_TYPE_PARAMETER;
|
import static org.jetbrains.jet.lang.types.TypeUtils.CANT_INFER_TYPE_PARAMETER;
|
||||||
|
import static org.jetbrains.jet.lang.types.TypeUtils.DONT_CARE;
|
||||||
|
|
||||||
public class DescriptorRendererImpl implements DescriptorRenderer {
|
public class DescriptorRendererImpl implements DescriptorRenderer {
|
||||||
private final boolean shortNames;
|
private final boolean shortNames;
|
||||||
@@ -213,7 +214,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String renderTypeWithoutEscape(@NotNull JetType type) {
|
private String renderTypeWithoutEscape(@NotNull JetType type) {
|
||||||
if (type == CANT_INFER_LAMBDA_PARAM_TYPE || type == CANT_INFER_TYPE_PARAMETER) {
|
if (type == CANT_INFER_LAMBDA_PARAM_TYPE || type == CANT_INFER_TYPE_PARAMETER || type == DONT_CARE) {
|
||||||
return "???";
|
return "???";
|
||||||
}
|
}
|
||||||
if (type.isError()) {
|
if (type.isError()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user