Tests for already working KT-3993 and KT-5427. These test cases pass at least since M11

This commit is contained in:
Mikhail Glukhikh
2015-03-31 17:15:46 +03:00
parent 9c1551bca9
commit 620b7954ac
5 changed files with 41 additions and 0 deletions
@@ -0,0 +1,10 @@
class User(val login : Boolean) {}
fun currentAccess(user: User?): Int {
return when {
user == null -> 0
// We should get smartcast here
<!DEBUG_INFO_SMARTCAST!>user<!>.login -> 1
else -> -1
}
}
@@ -0,0 +1,11 @@
package
internal fun currentAccess(/*0*/ user: User?): kotlin.Int
internal final class User {
public constructor User(/*0*/ login: kotlin.Boolean)
internal final val login: kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,5 @@
fun foo(p: String?): Int {
// We should get smart cast here
val x = if (p != null) { <!DEBUG_INFO_SMARTCAST!>p<!> } else "a"
return x.length()
}
@@ -0,0 +1,3 @@
package
internal fun foo(/*0*/ p: kotlin.String?): kotlin.Int
@@ -11187,12 +11187,24 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/smartCasts/varnotnull"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("kt3993.kt")
public void testKt3993() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3993.kt");
doTest(fileName);
}
@TestMetadata("kt4409.kt")
public void testKt4409() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt4409.kt");
doTest(fileName);
}
@TestMetadata("kt5427.kt")
public void testKt5427() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt5427.kt");
doTest(fileName);
}
@TestMetadata("kt5907.kt")
public void testKt5907() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt5907.kt");