added declared bound constraints directly to constraint system

added status 'hasViolatedUpperBound'
class TypeConstraintsImpl now stores constraint position for each constraint,
so we can filter out bound constraints and find out if the system is successful without them
This commit is contained in:
Svetlana Isakova
2013-09-26 14:05:49 +04:00
parent ac33ccc0fe
commit 731efd0781
16 changed files with 387 additions and 205 deletions
@@ -201,11 +201,11 @@ public class IdeRenderers {
}
};
public static final Renderer<InferenceErrorData> HTML_TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER =
new Renderer<InferenceErrorData>() {
public static final Renderer<ExtendedInferenceErrorData> HTML_TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER =
new Renderer<ExtendedInferenceErrorData>() {
@NotNull
@Override
public String render(@NotNull InferenceErrorData inferenceErrorData) {
public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) {
return renderUpperBoundViolatedInferenceError(inferenceErrorData, HtmlTabledDescriptorRenderer.create()).toString();
}
};
@@ -3,5 +3,24 @@ package i
fun foo<R, T: List<R>>(r: R, list: T) {}
fun test1(i: Int, collection: Collection<Int>) {
foo(i, collection)
}
foo(i, collection) //error
}
//--------------
fun bar<V : U, U>(v: V, u: MutableSet<U>) = u
fun test2(a: Any, s: MutableSet<String>) {
bar(a, s) //error
}
//--------------
trait A
class B
fun baz<T: R, R: B>(t: T, r: R) where T: A {
}
fun test3(a: A, b: B) {
baz(a, b) //error
}
@@ -0,0 +1,32 @@
<!-- upperBoundViolated2 -->
<html>
Type parameter bound for <b>
V</b>
in <table>
<tr>
<td width="10%">
</td>
<td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;">
<b>
fun</b>
&lt;V : U, U>
bar</td>
<td style="white-space:nowrap;font-weight:bold;">
(</td>
<td align="right" style="white-space:nowrap;font-weight:bold;">
v: V,</td>
<td align="right" style="white-space:nowrap;font-weight:bold;">
u: jet.MutableSet&lt;U&gt;</td>
<td style="white-space:nowrap;font-weight:bold;">
)</td>
<td style="white-space:nowrap;font-weight:bold;">
: jet.MutableSet&lt;U&gt;</td>
</tr>
</table>
is not satisfied: inferred type <font color=red>
<b>
jet.Any</b>
</font>
is not a subtype of <b>
jet.String</b>
</html>
@@ -0,0 +1,34 @@
<!-- upperBoundViolated3 -->
<html>
Type parameter bound for <b>
T</b>
in <table>
<tr>
<td width="10%">
</td>
<td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;">
<b>
fun</b>
&lt;T : R, R : i.B>
baz</td>
<td style="white-space:nowrap;font-weight:bold;">
(</td>
<td align="right" style="white-space:nowrap;font-weight:bold;">
t: T,</td>
<td align="right" style="white-space:nowrap;font-weight:bold;">
r: R</td>
<td style="white-space:nowrap;font-weight:bold;">
)</td>
<td style="white-space:nowrap;font-weight:bold;">
: jet.Unit <b>
where</b>
T : i.A</td>
</tr>
</table>
is not satisfied: inferred type <font color=red>
<b>
i.A</b>
</font>
is not a subtype of <b>
i.B</b>
</html>
@@ -103,7 +103,7 @@ public class DiagnosticMessageTest extends JetLiteFixture {
}
public void testUpperBoundViolated() throws Exception {
doTest("upperBoundViolated", 1, Errors.TYPE_INFERENCE_UPPER_BOUND_VIOLATED);
doTest("upperBoundViolated", 3, Errors.TYPE_INFERENCE_UPPER_BOUND_VIOLATED);
}
public void testTypeMismatchWithNothing() throws Exception {