JS/RTTI. Fix run-time type checking against Comparable
This commit is contained in:
committed by
Alexey Andreev
parent
390d71ac8d
commit
9bb60b48b2
@@ -0,0 +1,25 @@
|
||||
package foo
|
||||
|
||||
class A : Comparable<A> {
|
||||
override fun compareTo(other: A): Int = 0
|
||||
}
|
||||
|
||||
class B
|
||||
|
||||
fun test(x: Any?): Boolean = x is Comparable<*>
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(true, test(A()), "A()")
|
||||
assertEquals(true, test("abc"), "\"abc\"")
|
||||
assertEquals(true, test('a'), "\'a\'")
|
||||
assertEquals(true, test(0), "0")
|
||||
assertEquals(true, test(0.toChar()), "0.toChar()")
|
||||
assertEquals(true, test(0.toByte()), "0.toByte()")
|
||||
assertEquals(true, test(0.toShort()), "0.toShort()")
|
||||
assertEquals(true, test(0.toLong()), "0.toLong()")
|
||||
assertEquals(true, test(0.toDouble()), "0.toDouble()")
|
||||
assertEquals(true, test(0.toFloat()), "0.toFloat()")
|
||||
assertEquals(false, test(B()), "B()")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user