Kotlin界面实现“明确”

我有两个具有相同签名方法的接口,但返回类型不同。界面如下图所示,

interface IIntCalculation {
    fun Add(a:Int,b:Int): Int
}

interface IDoubleCalculation {
    fun Add(a:Int,b:Int): Double
}

当我尝试实现这些接口时,显然它将与相同的签名发生冲突,并显示为错误。重载冲突:public open fun Add(a:Int,b:Int):测试中定义的Int。计算,公开开放乐趣Add(a:Int,b:Int):在test.Calculation中定义了double。示例代码如下,

class Calculation : IIntCalculation,IDoubleCalculation {
    override fun Add(a: Int,b: Int): Int {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }

    override fun Add(a: Int,b: Int): Double {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }
}

那么,我可以明确实现这些接口吗?

在此先感谢您提供任何帮助和建议。

happy219 回答:Kotlin界面实现“明确”

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3144813.html

大家都在问