[Tests] Make sure desugaring works with context receivers
This commit is contained in:
committed by
TeamCityServer
parent
0bfea4fc52
commit
4d0eb74d79
+45
@@ -0,0 +1,45 @@
|
||||
// !LANGUAGE: +ContextReceivers
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
data class Result(val i: Int)
|
||||
|
||||
var operationScore = 0
|
||||
|
||||
context(Int)
|
||||
operator fun Result.unaryMinus(): Result {
|
||||
operationScore += this@Int
|
||||
return Result(-i)
|
||||
}
|
||||
|
||||
context(Int)
|
||||
operator fun Result.unaryPlus(): Result {
|
||||
operationScore += this@Int
|
||||
return Result(if (i < 0) (-i) else i)
|
||||
}
|
||||
|
||||
context(Int)
|
||||
operator fun Result.inc(): Result {
|
||||
operationScore += this@Int
|
||||
return Result(i + 1)
|
||||
}
|
||||
|
||||
context(Int)
|
||||
operator fun Result.dec(): Result {
|
||||
operationScore += this@Int
|
||||
return Result(i - 1)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = Result(0)
|
||||
with(1) {
|
||||
result++
|
||||
result++
|
||||
(-result)
|
||||
+result
|
||||
result--
|
||||
}
|
||||
return if (result.i == 1 && operationScore == 5) "OK" else "fail"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user