optimized ?. in non-nullable case

This commit is contained in:
Alex Tkachman
2011-12-03 19:26:21 +02:00
parent d8e6c18cfe
commit 90367ab138
3 changed files with 34 additions and 28 deletions
@@ -303,6 +303,18 @@ public class PrimitiveTypesTest extends CodegenTestCase {
assertTrue(generateToText().contains("IFNONNULL"));
}
public void testSafeNonnull () throws Exception {
loadText("fun box() = 10?.toString()");
// System.out.println(generateToText());
assertFalse(generateToText().contains("IFNULL"));
}
public void testSafeNullable () throws Exception {
loadText("val a : Int? = 10; fun box() = a?.toString()");
// System.out.println(generateToText());
assertTrue(generateToText().contains("IFNULL"));
}
public void testKt665() throws Exception {
loadText("fun f(x: Long, zzz: Long = 1): Long\n" +
"{\n" +