KT-12864: add Comparable interface to Enum metadata so that RTTI should handle is Comparable case correctly
This commit is contained in:
@@ -62,4 +62,8 @@ public class EnumTest extends SingleFileTranslationTest {
|
|||||||
public void testInitializationOrder() throws Exception {
|
public void testInitializationOrder() throws Exception {
|
||||||
checkFooBoxIsOk();
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testImplementsComparable() throws Exception {
|
||||||
|
checkFooBoxIsOk();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
X,
|
||||||
|
Y
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a : Any = A.X
|
||||||
|
assertEquals(0, (a as Comparable<A>).compareTo(A.X))
|
||||||
|
assertTrue((a as Comparable<A>).compareTo(A.Y) < 0)
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+8
-5
@@ -340,7 +340,10 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Kotlin.Enum = Kotlin.createClassNow(null,
|
lazyInitClasses.Enum = Kotlin.createClass(
|
||||||
|
function() {
|
||||||
|
return [Kotlin.Comparable];
|
||||||
|
},
|
||||||
function () {
|
function () {
|
||||||
this.name$ = void 0;
|
this.name$ = void 0;
|
||||||
this.ordinal$ = void 0;
|
this.ordinal$ = void 0;
|
||||||
@@ -665,19 +668,19 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Kotlin.Runnable = Kotlin.createClassNow(null, null, {
|
Kotlin.Runnable = Kotlin.createTraitNow(null, null, {
|
||||||
run: throwAbstractFunctionInvocationError("Runnable#run")
|
run: throwAbstractFunctionInvocationError("Runnable#run")
|
||||||
});
|
});
|
||||||
|
|
||||||
Kotlin.Comparable = Kotlin.createClassNow(null, null, {
|
Kotlin.Comparable = Kotlin.createTraitNow(null, null, {
|
||||||
compareTo: throwAbstractFunctionInvocationError("Comparable#compareTo")
|
compareTo: throwAbstractFunctionInvocationError("Comparable#compareTo")
|
||||||
});
|
});
|
||||||
|
|
||||||
Kotlin.Appendable = Kotlin.createClassNow(null, null, {
|
Kotlin.Appendable = Kotlin.createTraitNow(null, null, {
|
||||||
append: throwAbstractFunctionInvocationError("Appendable#append")
|
append: throwAbstractFunctionInvocationError("Appendable#append")
|
||||||
});
|
});
|
||||||
|
|
||||||
Kotlin.Closeable = Kotlin.createClassNow(null, null, {
|
Kotlin.Closeable = Kotlin.createTraitNow(null, null, {
|
||||||
close: throwAbstractFunctionInvocationError("Closeable#close")
|
close: throwAbstractFunctionInvocationError("Closeable#close")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user