optimized sure for non-nullable types

This commit is contained in:
Alex Tkachman
2011-12-03 18:56:54 +02:00
parent d33d1367de
commit d8e6c18cfe
5 changed files with 36 additions and 13 deletions
@@ -291,6 +291,18 @@ public class PrimitiveTypesTest extends CodegenTestCase {
blackBox();
}
public void testSureNonnull () throws Exception {
loadText("fun box() = 10.sure().toString()");
// System.out.println(generateToText());
assertFalse(generateToText().contains("IFNONNULL"));
}
public void testSureNullable () throws Exception {
loadText("val a : Int? = 10; fun box() = a.sure().toString()");
// System.out.println(generateToText());
assertTrue(generateToText().contains("IFNONNULL"));
}
public void testKt665() throws Exception {
loadText("fun f(x: Long, zzz: Long = 1): Long\n" +
"{\n" +
@@ -8,7 +8,7 @@ import java.lang.reflect.Method;
public class JetNpeTest extends CodegenTestCase {
public void testStackTrace () {
try {
Intrinsics.sure(null);
Intrinsics.throwNpe();
fail("No Sure thrown");
}
catch (NullPointerException e) {