Add test on smartcasts with reified types

This test introduces very special (for current implementation) case,
when we have smartcast indirectly, via some reified type parameter.

It covers recursive call inSmartCastManager.checkAndRecordPossibleCast(),
which wasn't previously covered by any test in testbase.
This commit is contained in:
Dmitry Savvinov
2017-11-20 18:00:32 +03:00
parent 440b6d9934
commit b8447d6d97
4 changed files with 27 additions and 0 deletions
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
inline fun <reified T : CharSequence?> foo(y: Any?) {
if (y is T?) {
if (y != null) {
bar(<!DEBUG_INFO_SMARTCAST!>y<!>)
}
}
}
fun bar(x: CharSequence) {}
@@ -0,0 +1,4 @@
package
public fun bar(/*0*/ x: kotlin.CharSequence): kotlin.Unit
public inline fun </*0*/ reified T : kotlin.CharSequence?> foo(/*0*/ y: kotlin.Any?): kotlin.Unit
@@ -20818,6 +20818,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("severalSmartCastsOnReified.kt")
public void testSeveralSmartCastsOnReified() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/severalSmartCastsOnReified.kt");
doTest(fileName);
}
@TestMetadata("shortIfExprNotNull.kt")
public void testShortIfExprNotNull() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/shortIfExprNotNull.kt");
@@ -20818,6 +20818,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
doTest(fileName);
}
@TestMetadata("severalSmartCastsOnReified.kt")
public void testSeveralSmartCastsOnReified() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/severalSmartCastsOnReified.kt");
doTest(fileName);
}
@TestMetadata("shortIfExprNotNull.kt")
public void testShortIfExprNotNull() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/shortIfExprNotNull.kt");