KT-10706: do not report IMPLICIT_CAST_TO_ANY on expressions of type Nothing
This commit is contained in:
@@ -744,7 +744,8 @@ public class ControlFlowInformationProvider {
|
|||||||
for (KtExpression branchExpression : branchExpressions) {
|
for (KtExpression branchExpression : branchExpressions) {
|
||||||
if (branchExpression == null) continue;
|
if (branchExpression == null) continue;
|
||||||
KotlinType branchType = trace.getType(branchExpression);
|
KotlinType branchType = trace.getType(branchExpression);
|
||||||
assert branchType != null : "Branch expression type should be non-null";
|
if (branchType == null) continue;
|
||||||
|
if (KotlinBuiltIns.isNothing(branchType)) continue;
|
||||||
trace.report(IMPLICIT_CAST_TO_ANY.on(getResultingExpression(branchExpression), branchType, expressionType));
|
trace.report(IMPLICIT_CAST_TO_ANY.on(getResultingExpression(branchExpression), branchType, expressionType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fun TODO(): Nothing = null!!
|
||||||
|
|
||||||
|
fun fn(c: Char?): Any? =
|
||||||
|
if (c == null) TODO()
|
||||||
|
else when (<!DEBUG_INFO_SMARTCAST!>c<!>) {
|
||||||
|
'a' -> when (<!DEBUG_INFO_SMARTCAST!>c<!>) {
|
||||||
|
'B' -> <!IMPLICIT_CAST_TO_ANY!>1<!>
|
||||||
|
'C' -> <!IMPLICIT_CAST_TO_ANY!>"sdf"<!>
|
||||||
|
else -> TODO()
|
||||||
|
}
|
||||||
|
else -> TODO()
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun TODO(): kotlin.Nothing
|
||||||
|
public fun fn(/*0*/ c: kotlin.Char?): kotlin.Any?
|
||||||
@@ -3360,6 +3360,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt10706.kt")
|
||||||
|
public void testKt10706() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/kt10706.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt1075.kt")
|
@TestMetadata("kt1075.kt")
|
||||||
public void testKt1075() throws Exception {
|
public void testKt1075() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/kt1075.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/kt1075.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user