Files
kotlin-fork/compiler/testData/codegen/box/increment/classWithGetSet.kt
T
Juan Chen 573188bdc4 [FIR2IR]: fix translation of this references in instance methods
Currently FirThisReceiverExpression of instance methods are translated
to references of the class' thisReceiver,
not the method's dispatch receiver,
which causes problems with IrFrameMap::typeOf,
as the class' thisReceiver is not in the typeMap.

This commit translates non-qualified "this" references of
instance methods to references of the methods' dispatch receiver.
2020-01-10 10:43:07 +03:00

117 lines
2.6 KiB
Kotlin
Vendored

class AByte(var value: Byte) {
operator fun get(i: Int) = value
operator fun set(i: Int, newValue: Byte) {
value = newValue
}
}
class AShort(var value: Short) {
operator fun get(i: Int) = value
operator fun set(i: Int, newValue: Short) {
value = newValue
}
}
class AInt(var value: Int) {
operator fun get(i: Int) = value
operator fun set(i: Int, newValue: Int) {
value = newValue
}
}
class ALong(var value: Long) {
operator fun get(i: Int) = value
operator fun set(i: Int, newValue: Long) {
value = newValue
}
}
class AFloat(var value: Float) {
operator fun get(i: Int) = value
operator fun set(i: Int, newValue: Float) {
value = newValue
}
}
class ADouble(var value: Double) {
operator fun get(i: Int) = value
operator fun set(i: Int, newValue: Double) {
value = newValue
}
}
fun box(): String {
val aByte = AByte(1)
var bByte: Byte = 1
val aShort = AShort(1)
var bShort: Short = 1
val aInt = AInt(1)
var bInt: Int = 1
val aLong = ALong(1)
var bLong: Long = 1
val aFloat = AFloat(1.0f)
var bFloat: Float = 1.0f
val aDouble = ADouble(1.0)
var bDouble: Double = 1.0
aByte[0]++
bByte++
if (aByte[0] != bByte) return "Failed post-increment Byte: ${aByte[0]} != $bByte"
aByte[0]--
bByte--
if (aByte[0] != bByte) return "Failed post-decrement Byte: ${aByte[0]} != $bByte"
aShort[0]++
bShort++
if (aShort[0] != bShort) return "Failed post-increment Short: ${aShort[0]} != $bShort"
aShort[0]--
bShort--
if (aShort[0] != bShort) return "Failed post-decrement Short: ${aShort[0]} != $bShort"
aInt[0]++
bInt++
if (aInt[0] != bInt) return "Failed post-increment Int: ${aInt[0]} != $bInt"
aInt[0]--
bInt--
if (aInt[0] != bInt) return "Failed post-decrement Int: ${aInt[0]} != $bInt"
aLong[0]++
bLong++
if (aLong[0] != bLong) return "Failed post-increment Long: ${aLong[0]} != $bLong"
aLong[0]--
bLong--
if (aLong[0] != bLong) return "Failed post-decrement Long: ${aLong[0]} != $bLong"
aFloat[0]++
bFloat++
if (aFloat[0] != bFloat) return "Failed post-increment Float: ${aFloat[0]} != $bFloat"
aFloat[0]--
bFloat--
if (aFloat[0] != bFloat) return "Failed post-decrement Float: ${aFloat[0]} != $bFloat"
aDouble[0]++
bDouble++
if (aDouble[0] != bDouble) return "Failed post-increment Double: ${aDouble[0]} != $bDouble"
aDouble[0]--
bDouble--
if (aDouble[0] != bDouble) return "Failed post-decrement Double: ${aDouble[0]} != $bDouble"
return "OK"
}