Fixed message for TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH error

This commit is contained in:
Svetlana Isakova
2014-12-17 15:34:57 +03:00
parent 7b09e85717
commit 9d09a4d1b4
4 changed files with 21 additions and 1 deletions
@@ -225,7 +225,8 @@ public abstract class AbstractTracingStrategy implements TracingStrategy {
ConstraintSystem systemWithoutExpectedTypeConstraint =
((ConstraintSystemImpl) constraintSystem).filterConstraintsOut(EXPECTED_TYPE_POSITION.position());
JetType substitutedReturnType = systemWithoutExpectedTypeConstraint.getResultingSubstitutor().substitute(declaredReturnType, Variance.INVARIANT);
JetType substitutedReturnType = systemWithoutExpectedTypeConstraint.getResultingSubstitutor().substitute(
declaredReturnType, Variance.OUT_VARIANCE);
assert substitutedReturnType != null; //todo
assert !noExpectedType(data.expectedType) : "Expected type doesn't exist, but there is an expected type mismatch error";
@@ -0,0 +1,9 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
fun <T> foo(a1: Array<T>, a2: Array<out T>): T = null!!
fun test(a1: Array<in Int>, a2: Array<Int>) {
val c: Int = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH(kotlin.Int; kotlin.Any?)!>foo<!>(a1, a2)
}
@@ -0,0 +1,4 @@
package
internal fun </*0*/ T> foo(/*0*/ a1: kotlin.Array<T>, /*1*/ a2: kotlin.Array<out T>): T
internal fun test(/*0*/ a1: kotlin.Array<in kotlin.Int>, /*1*/ a2: kotlin.Array<kotlin.Int>): kotlin.Unit
@@ -5178,6 +5178,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("expectedTypeMismatchWithInVariance.kt")
public void testExpectedTypeMismatchWithInVariance() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes/expectedTypeMismatchWithInVariance.kt");
doTest(fileName);
}
@TestMetadata("kt2570.kt")
public void testKt2570() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes/kt2570.kt");