Kotlin 科特林宣言冲突

Kotlin 科特林宣言冲突,kotlin,Kotlin,我有个问题。除了添加@JvmName,还有其他方法修复此代码吗 class Test() { fun <T> apply(calc: (String, List<Double>, Double, Double) -> T): T { return calc("a", listOf(), 1.2, 3.4) } fun <T> apply(calc: (String, Double, Double, Double)

我有个问题。除了添加
@JvmName
,还有其他方法修复此代码吗

class Test() {
    fun <T> apply(calc: (String, List<Double>, Double, Double) -> T): T {
        return calc("a", listOf(), 1.2, 3.4)
    }

    fun <T> apply(calc: (String, Double, Double, Double) -> T): T {
        return calc("a", 1.2, 3.4, 5.6)
    }
}
类测试(){
有趣的应用(计算:(字符串,列表,双精度,双精度)->T:T{
返回计算(“a”,listOf(),1.2,3.4)
}
有趣的应用(计算:(字符串,双精度,双精度)->T:T{
返回计算(“a”、1.2、3.4、5.6)
}
}
上述代码产生以下错误:

Error:(375, 9) Kotlin: Platform declaration clash: The following declarations have the same JVM signature (apply(Lkotlin/jvm/functions/Function4;)Ljava/lang/Object;):
fun <T> apply(calc: (String, Double, Double, Double) -> T): T defined in Sample.Test
fun <T> apply(calc: (String, List<Double>, Double, Double) -> T): T defined in Sample.Test
错误:(375,9)Kotlin:平台声明冲突:以下声明具有相同的JVM签名(apply(Lkotlin/JVM/functions/Function4;)Ljava/lang/Object;):
fun apply(计算:(字符串,双精度,双精度)->T):T在Sample.Test中定义
fun apply(计算:(字符串,列表,双精度,双精度)->T):T在Sample.Test中定义

看起来没有办法,因为Kotlin生成的通用代码使用Function4作为参数类型。它是一个由4个泛型参数组成的接口,因此无论类型如何,所有参数看起来都是一样的

/** A function that takes 4 arguments. */
public interface Function4<in P1, in P2, in P3, in P4, out R> : Function<R> {
   /** Invokes the function with the specified arguments. */
   public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R
}
/**一个接受4个参数的函数*/
公共接口函数4:函数{
/**使用指定的参数调用函数*/
公共操作符乐趣调用(p1:p1,p2:p2,p3:p3,p4:p4):R
}