diff --git a/compiler/testData/codegen/box/classes/implementComparableInSubclass.kt b/compiler/testData/codegen/box/classes/implementComparableInSubclass.kt new file mode 100644 index 00000000000..4d7504f26ac --- /dev/null +++ b/compiler/testData/codegen/box/classes/implementComparableInSubclass.kt @@ -0,0 +1,22 @@ +// See KT-12865 + +package foo + +abstract class Base { + val x = 23 +} + +class Derived : Base(), Comparable { + val y = 42 + override fun compareTo(other: Derived): Int { + throw UnsupportedOperationException("not implemented") + } +} + +fun box(): String { + val b = Derived() + if (b.x != 23) return "fail1: ${b.x}" + if (b.y != 42) return "fail2: ${b.y}" + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index ca719c3f1df..a6af9174904 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -2599,6 +2599,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("implementComparableInSubclass.kt") + public void testImplementComparableInSubclass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classes/implementComparableInSubclass.kt"); + doTest(fileName); + } + @TestMetadata("inheritSetAndHashSet.kt") public void testInheritSetAndHashSet() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classes/inheritSetAndHashSet.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/ClassesTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/ClassesTestGenerated.java index f58fcce933f..45f70809d27 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/ClassesTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/ClassesTestGenerated.java @@ -227,6 +227,12 @@ public class ClassesTestGenerated extends AbstractClassesTest { doTest(fileName); } + @TestMetadata("implementComparableInSubclass.kt") + public void testImplementComparableInSubclass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classes/implementComparableInSubclass.kt"); + doTest(fileName); + } + @TestMetadata("inheritSetAndHashSet.kt") public void testInheritSetAndHashSet() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classes/inheritSetAndHashSet.kt");