KT-2883 Type inference fails due to non-Unit value returned
#KT-2883 fixed
This commit is contained in:
+1
-1
@@ -368,7 +368,7 @@ public class ExpressionTypingServices {
|
|||||||
mismatchFound[0] = true;
|
mismatchFound[0] = true;
|
||||||
}
|
}
|
||||||
if (TYPE_INFERENCE_ERRORS.contains(diagnostic.getFactory()) &&
|
if (TYPE_INFERENCE_ERRORS.contains(diagnostic.getFactory()) &&
|
||||||
PsiTreeUtil.getParentOfType(diagnostic.getPsiElement(), JetQualifiedExpression.class, false) == expressionToWatch) {
|
PsiTreeUtil.isAncestor(expressionToWatch, diagnostic.getPsiElement(), false)) {
|
||||||
mismatchFound[0] = true;
|
mismatchFound[0] = true;
|
||||||
}
|
}
|
||||||
super.report(diagnostic);
|
super.report(diagnostic);
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
//KT-2883 Type inference fails due to non-Unit value returned
|
||||||
|
package a
|
||||||
|
|
||||||
|
public fun doAction(<!UNUSED_PARAMETER!>action<!> : () -> Unit){
|
||||||
|
}
|
||||||
|
|
||||||
|
class Y<TItem>(val itemToString: (TItem) -> String){
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <TItem> bar(<!UNUSED_PARAMETER!>context<!> : Y<TItem>) : TItem{
|
||||||
|
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
|
|
||||||
|
fun foo(){
|
||||||
|
val stringToString : (String) -> String = { it }
|
||||||
|
doAction({bar(Y<String>(stringToString))})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> bar(t: T): T = t
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
|
||||||
|
doAction { bar(12) }
|
||||||
|
|
||||||
|
val <!UNUSED_VARIABLE!>u<!>: Unit = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>bar<!>(11)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testWithoutInference(col: MutableCollection<Int>) {
|
||||||
|
|
||||||
|
doAction { col.add(2) }
|
||||||
|
|
||||||
|
val <!UNUSED_VARIABLE!>u<!>: Unit = <!TYPE_MISMATCH!>col.add(2)<!>
|
||||||
|
}
|
||||||
@@ -2222,6 +2222,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
|||||||
doTest("compiler/testData/diagnostics/tests/inference/regressions/kt2842.kt");
|
doTest("compiler/testData/diagnostics/tests/inference/regressions/kt2842.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt2883.kt")
|
||||||
|
public void testKt2883() throws Exception {
|
||||||
|
doTest("compiler/testData/diagnostics/tests/inference/regressions/kt2883.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3007.kt")
|
@TestMetadata("kt3007.kt")
|
||||||
public void testKt3007() throws Exception {
|
public void testKt3007() throws Exception {
|
||||||
doTest("compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt");
|
doTest("compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user