Files
kotlin-fork/compiler/testData/diagnostics/tests/IncDec.fir.kt
T
Denis Zharkov 47ecaa5b06 FIR: Fix scope intersection types
Otherwise overload resolution ambiguity is reported in the test
2020-01-30 17:12:50 +03:00

47 lines
559 B
Kotlin
Vendored

class IncDec() {
operator fun inc() : IncDec = this
operator fun dec() : IncDec = this
}
fun testIncDec() {
var x = IncDec()
x++
++x
x--
--x
x = x++
x = x--
x = ++x
x = --x
}
class WrongIncDec() {
operator fun inc() : Int = 1
operator fun dec() : Int = 1
}
fun testWrongIncDec() {
var x = WrongIncDec()
x++
++x
x--
--x
}
class UnitIncDec() {
operator fun inc() : Unit {}
operator fun dec() : Unit {}
}
fun testUnitIncDec() {
var x = UnitIncDec()
x++
++x
x--
--x
x = x++
x = x--
x = ++x
x = --x
}