Delegating function variables in Kotlin with generic class

I’m currently working on an application that requires delegating function variables. I’ve encountered some problems when trying to do so. Here’s the code of a minimal reproducible example:

package org.prismsus.tank

import kotlin.reflect.KProperty
fun addFunc(a : Int, b : Int) : Int {
    return a + b
}

class Test{
    inner class PrintFuncCall1{
        operator fun getValue(thisRef: Any?, property: KProperty<*>): (Int, Int) -> Int {
            fun temp(a : Int, b : Int) : Int {
                println("Function ${property.name}")
                return addFunc(a, b)
            }
            return ::temp
        }
    }
    val delegatedFun1 : (Int, Int) -> Int by PrintFuncCall1()


    inner class PrintFuncCall2<F : (Array<out Any>) -> R, R>{
        operator fun getValue(thisRef : Any?, property : KProperty<*>) : (Array<out Any>) -> R{
            fun temp(vararg params : Any) : R{
                println("Function ${property.name}")
                println("Params: ${params.joinToString()}")
                return addFunc(params[0] as Int, params[1] as Int) as R
            }
            return ::temp
        }
    }

    val delegatedFun2 : (Int, Int) -> Int by PrintFuncCall2()
}

fun main(){
    val test = Test()
    println(test.delegatedFun1(1, 2))
    println(test.delegatedFun2(3, 4))
}

Here delegatedFun1 and PrintFuncCall1 worked fine. However, I tried to modify the delegate class to a generic class and found that this didn’t work. Specifically, I got this compilation error for delegatedFun2 and PrintFuncCall2:

Property delegate must have a 'getValue(Test, KProperty<*>)' method. None of the following functions is suitable: 
public final operator fun getValue(thisRef: Any?, property: KProperty<*>): (Array<out Any>) -> ??? defined in org.prismsus.tank.Test.PrintFuncCall2

I don’t quite get why getValue requires thisRef to be of type Test, which is the type of the larger class. This is especially strange as I’m delegating a variable of type (Int, Int) -> Int. Further, even if I tried to change the signature of getValue to getValue(thisRef : Test, property : KProperty<*>), I got the following error:

Property delegate must have a 'getValue(Test, KProperty<*>)' method. None of the following functions is suitable: 
public final operator fun getValue(thisRef: Test, property: KProperty<*>): (Array<out Any>) -> ??? defined in org.prismsus.tank.Test.PrintFuncCall2

Besides these, a minor question I have is about Kotlin’s constrain mechanism to type parameters. My intention for PrintFuncCall2 is to mark F as the type of the function, and R as the return value of function F. However, when changing the signature of getValue from getValue(thisRef : Test, property : KProperty<*>) : (Array<out Any>) -> R to getValue(thisRef : Test, property : KProperty<*>) : F, I got this message from IDE on the line return ::temp:

Required:
KFunction1<Array<out Any>, R>
Found:
F

Isn’t that these two supposed to be the same thing?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật