Use mapping mode for inline class underlying type without wrapping
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR, JS_IR
|
||||
|
||||
inline class GCmp<T>(val xc: Comparable<T>)
|
||||
inline class GSCmp<T>(val sc: Comparable<String>)
|
||||
inline class SCmp(val sc: Comparable<String>)
|
||||
inline class ICmp(val intc: Comparable<Int>)
|
||||
inline class GICmp<T>(val intc: Comparable<Int>)
|
||||
|
||||
inline class II(val i: Int) : Comparable<II> {
|
||||
override fun compareTo(other: II): Int {
|
||||
return i.compareTo(other.i)
|
||||
}
|
||||
}
|
||||
|
||||
inline class IICmp(val iic: Comparable<II>)
|
||||
inline class GIICmp<T>(val iic: Comparable<II>)
|
||||
|
||||
fun testGCmp(x: GCmp<String>) {
|
||||
if (x.xc.compareTo("OK") != 0) throw AssertionError()
|
||||
}
|
||||
|
||||
fun testGSCmp(x: GSCmp<Any>) {
|
||||
if (x.sc.compareTo("OK") != 0) throw AssertionError()
|
||||
}
|
||||
|
||||
fun testSCmp(x: SCmp) {
|
||||
if (x.sc.compareTo("OK") != 0) throw AssertionError()
|
||||
}
|
||||
|
||||
fun testICmp(x: ICmp) {
|
||||
if (x.intc.compareTo(42) != 0) throw AssertionError()
|
||||
}
|
||||
|
||||
fun testGICmp(x: GICmp<Any>) {
|
||||
if (x.intc.compareTo(42) != 0) throw AssertionError()
|
||||
}
|
||||
|
||||
fun testIICmp(x: IICmp) {
|
||||
if (x.iic.compareTo(II(42)) != 0) throw AssertionError()
|
||||
}
|
||||
|
||||
fun testGIICmp(x: GIICmp<Any>) {
|
||||
if (x.iic.compareTo(II(42)) != 0) throw AssertionError()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
testGCmp(GCmp("OK"))
|
||||
testGSCmp(GSCmp<Any>("OK"))
|
||||
testSCmp(SCmp("OK"))
|
||||
testICmp(ICmp(42))
|
||||
testGICmp(GICmp<Any>(42))
|
||||
testIICmp(IICmp(II(42)))
|
||||
testGIICmp(GIICmp<Any>(II(42)))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR, JS_IR
|
||||
|
||||
inline class GList<T>(val xs: List<T>)
|
||||
inline class GSList<T>(val ss: List<String>)
|
||||
inline class SList(val ss: List<String>)
|
||||
inline class IList(val ints: List<Int>)
|
||||
inline class GIList<T>(val ints: List<Int>)
|
||||
|
||||
inline class II(val i: Int)
|
||||
inline class IIList(val iis: List<II>)
|
||||
inline class GIIList<T>(val iis: List<II>)
|
||||
|
||||
fun testGList(gl: GList<String>) {
|
||||
if (gl.xs[0] != "OK") throw AssertionError()
|
||||
}
|
||||
|
||||
fun testGSList(sl: GSList<String>) {
|
||||
if (sl.ss[0] != "OK") throw AssertionError()
|
||||
}
|
||||
|
||||
fun testSList(sl: SList) {
|
||||
if (sl.ss[0] != "OK") throw AssertionError()
|
||||
}
|
||||
|
||||
fun testIList(il: IList) {
|
||||
if (il.ints[0] != 42) throw AssertionError()
|
||||
}
|
||||
|
||||
fun testGIList(gil: GIList<Any>) {
|
||||
if (gil.ints[0] != 42) throw AssertionError()
|
||||
}
|
||||
|
||||
fun testIIList(iil: IIList) {
|
||||
if (iil.iis[0].i != 42) throw AssertionError()
|
||||
}
|
||||
|
||||
fun testGIIList(giil: GIIList<Any>) {
|
||||
if (giil.iis[0].i != 42) throw AssertionError()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
testGList(GList(listOf("OK")))
|
||||
testGSList(GSList(listOf("OK")))
|
||||
testSList(SList(listOf("OK")))
|
||||
testIList(IList(listOf(42)))
|
||||
testGIList(GIList<Any>(listOf(42)))
|
||||
testIIList(IIList(listOf(II(42))))
|
||||
testGIIList(GIIList<Any>(listOf(II(42))))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user