Files
kotlin-fork/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.kt.txt
T
Dmitriy Novozhilov b454fcc1e0 [FIR] Save IR dumps to .ir.txt files instead of .txt in tests
This is needed to avoid clashes between different dumps from different
  handlers
2021-10-12 17:26:36 +03:00

112 lines
2.2 KiB
Plaintext
Vendored

fun interface IFoo {
abstract fun foo(i: Int)
}
fun interface IFoo2 : IFoo {
}
object A {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
object B {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
operator fun A.get(i: IFoo): Int {
return 1
}
operator fun A.set(i: IFoo, newValue: Int) {
}
operator fun B.get(i: IFoo): Int {
return 1
}
operator fun B.set(i: IFoo2, newValue: Int) {
}
fun withVararg(vararg xs: Int): Int {
return 42
}
fun test1() {
{ // BLOCK
val tmp0_array: A = A
val tmp2_sam: IFoo = { // BLOCK
local fun withVararg(p0: Int) {
withVararg(xs = [p0]) /*~> Unit */
}
::withVararg
} /*-> IFoo */
tmp0_array.set(i = tmp2_sam, newValue = tmp0_array.get(i = tmp2_sam).plus(other = 1))
}
}
fun test2() {
{ // BLOCK
val tmp0_array: B = B
val tmp2_sam: IFoo2 = { // BLOCK
local fun withVararg(p0: Int) {
withVararg(xs = [p0]) /*~> Unit */
}
::withVararg
} /*-> IFoo2 */
tmp0_array.set(i = tmp2_sam, newValue = tmp0_array.get(i = tmp2_sam).plus(other = 1))
}
}
fun test3(fn: Function1<Int, Unit>) {
{ // BLOCK
val tmp0_array: A = A
val tmp2_sam: IFoo = fn /*-> IFoo */
tmp0_array.set(i = tmp2_sam, newValue = tmp0_array.get(i = tmp2_sam).plus(other = 1))
}
}
fun test4(fn: Function1<Int, Unit>) {
when {
fn is IFoo -> { // BLOCK
{ // BLOCK
val tmp0_array: A = A
val tmp1_index0: Function1<Int, Unit> = fn
tmp0_array.set(i = tmp1_index0 /*as IFoo */, newValue = tmp0_array.get(i = tmp1_index0 /*as IFoo */).plus(other = 1))
}
}
}
}
fun test5(a: Any) {
a as Function1<Int, Unit> /*~> Unit */
{ // BLOCK
val tmp0_array: A = A
val tmp2_sam: IFoo = a /*as Function1<Int, Unit> */ /*-> IFoo */
tmp0_array.set(i = tmp2_sam, newValue = tmp0_array.get(i = tmp2_sam).plus(other = 1))
}
}
fun test6(a: Any) {
a as Function1<Int, Unit> /*~> Unit */
a as IFoo /*~> Unit */
{ // BLOCK
val tmp0_array: A = A
val tmp1_index0: Any = a
tmp0_array.set(i = tmp1_index0 /*as IFoo */, newValue = tmp0_array.get(i = tmp1_index0 /*as IFoo */).plus(other = 1))
}
}