Extra test with smart cast to 'T'

This commit is contained in:
Mikhail Glukhikh
2016-01-20 16:42:58 +03:00
parent d5ffa0bbca
commit 7ac55cefcb
5 changed files with 43 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
class Wrapper<T>(var x: T)
inline fun <reified T> change(w: Wrapper<T>, x: Any?) {
if (x is T) {
w.x = x
}
}
fun box(): String {
val w = Wrapper<String>("FAIL")
change(w, "OK")
return w.x
}
@@ -0,0 +1,7 @@
class Wrapper<T>(var x: T)
inline fun <reified T> change(w: Wrapper<T>, x: Any?) {
if (x is T) {
w.x = <!DEBUG_INFO_SMARTCAST!>x<!>
}
}
@@ -0,0 +1,11 @@
package
public inline fun </*0*/ reified T> change(/*0*/ w: Wrapper<T>, /*1*/ x: kotlin.Any?): kotlin.Unit
public final class Wrapper</*0*/ T> {
public constructor Wrapper</*0*/ T>(/*0*/ x: T)
public final var x: T
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
}
@@ -15615,6 +15615,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("genericSet.kt")
public void testGenericSet() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/genericSet.kt");
doTest(fileName);
}
@TestMetadata("ifCascadeExprNotNull.kt")
public void testIfCascadeExprNotNull() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/ifCascadeExprNotNull.kt");
@@ -7357,6 +7357,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("genericSet.kt")
public void testGenericSet() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/smartCasts/genericSet.kt");
doTest(fileName);
}
@TestMetadata("implicitExtensionReceiver.kt")
public void testImplicitExtensionReceiver() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/smartCasts/implicitExtensionReceiver.kt");