[Tests] Make sure desugaring works with context receivers
This commit is contained in:
committed by
TeamCityServer
parent
0bfea4fc52
commit
4d0eb74d79
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
data class MyContainer {
|
||||
constructor(i: Int) /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
var i: Int
|
||||
field = i
|
||||
get
|
||||
set
|
||||
|
||||
operator fun component1(): Int {
|
||||
return <this>.#i
|
||||
}
|
||||
|
||||
fun copy(i: Int = <this>.#i): MyContainer {
|
||||
return MyContainer(i = i)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "MyContainer(" + "i=" + <this>.#i + ")"
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return <this>.#i.hashCode()
|
||||
}
|
||||
|
||||
override operator fun equals(other: Any?): Boolean {
|
||||
when {
|
||||
EQEQEQ(arg0 = <this>, arg1 = other) -> return true
|
||||
}
|
||||
when {
|
||||
other !is MyContainer -> return false
|
||||
}
|
||||
val tmp0_other_with_cast: MyContainer = other as MyContainer
|
||||
when {
|
||||
EQEQ(arg0 = <this>.#i, arg1 = tmp0_other_with_cast.#i).not() -> return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var operationScore: Int
|
||||
field = 0
|
||||
get
|
||||
set
|
||||
|
||||
operator fun MyContainer.get(<this>: Int, index: Int): Int {
|
||||
{ // BLOCK
|
||||
<set-operationScore>(<set-?> = <get-operationScore>().plus(other = <this>))
|
||||
}
|
||||
return when {
|
||||
EQEQ(arg0 = index, arg1 = 0) -> <this>.<get-i>()
|
||||
else -> -1
|
||||
}
|
||||
}
|
||||
|
||||
operator fun MyContainer.plusAssign(<this>: Int, other: MyContainer) {
|
||||
{ // BLOCK
|
||||
<set-operationScore>(<set-?> = <get-operationScore>().plus(other = <this>))
|
||||
}
|
||||
{ // BLOCK
|
||||
val tmp0_this: MyContainer = <this>
|
||||
tmp0_this.<set-i>(<set-?> = tmp0_this.<get-i>().plus(other = other.<get-i>()))
|
||||
}
|
||||
}
|
||||
|
||||
operator fun MyContainer.inc(<this>: Int): MyContainer {
|
||||
{ // BLOCK
|
||||
<set-operationScore>(<set-?> = <get-operationScore>().plus(other = <this>))
|
||||
}
|
||||
return MyContainer(i = <this>.<get-i>().plus(other = 1))
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var myContainer: MyContainer = MyContainer(i = 0)
|
||||
with<Int, Unit>(receiver = 1, block = local fun Int.<anonymous>() {
|
||||
myContainer.plusAssign(<this> = $this$with, other = MyContainer(i = { // BLOCK
|
||||
val tmp0: MyContainer = myContainer
|
||||
myContainer = tmp0.inc(<this> = $this$with)
|
||||
tmp0
|
||||
}.get(<this> = $this$with, index = 0)))
|
||||
}
|
||||
)
|
||||
return when {
|
||||
when {
|
||||
EQEQ(arg0 = myContainer.<get-i>(), arg1 = 1) -> EQEQ(arg0 = <get-operationScore>(), arg1 = 3)
|
||||
else -> false
|
||||
} -> "OK"
|
||||
else -> "fail"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user