Don't fail when using Unit class object as a value

#KT-4243 Fixed
This commit is contained in:
Alexander Udalov
2013-12-03 18:02:37 +04:00
parent fa7076a4fa
commit 4ecd1a8f68
3 changed files with 25 additions and 0 deletions
@@ -0,0 +1,13 @@
fun box(): String {
Unit
val a = Unit
val b = Unit
if (a != b) return "Fail a != b"
if (Unit != Unit) return "Fail Unit != Unit"
if (a.VALUE != Unit.VALUE) return "Fail a.VALUE != Unit.VALUE"
return "OK"
}
@@ -4565,6 +4565,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/box/unit"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("unitClassObject.kt")
public void testUnitClassObject() throws Exception {
doTest("compiler/testData/codegen/box/unit/unitClassObject.kt");
}
@TestMetadata("UnitValue.kt")
public void testUnitValue() throws Exception {
doTest("compiler/testData/codegen/box/unit/UnitValue.kt");
+7
View File
@@ -22,6 +22,8 @@ import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver;
public class Unit {
public static final Unit VALUE = new Unit();
public static final object object$ = new object();
private Unit() {
}
@@ -39,4 +41,9 @@ public class Unit {
public int hashCode() {
return 239;
}
public static class object {
private object() {
}
}
}