我使用从库中的部分代码:https://github.com/Netflix-Skunkworks/rewrite如何用lambda调用多个类似签名的Kotlin方法?
当我调用它的方法之一,我遇到一个IDE错误:
None of the following functions can be called with the arguments supplied.
目标的方法有两个类似的特征:
data class CompilationUnit(...){
fun refactor() = Refactor(this)
fun refactor(ops: Refactor.() -> Unit): Refactor {
val r = refactor()
ops(r)
return r
}
fun refactor(ops: Consumer<Refactor>): Refactor {
val r = refactor()
ops.accept(r)
return r
}
}
在科特林调用代码:
val unit: CompilationUnit =...
unit.refactor{ tx ->
doSomeThing()
}
这与调用拉姆达是OK在Java中:
CompilationUnit unit = ....
unit.refactor(tx -> {
doSomeThing()
});