Tag: 重载解析

如何调用与lambda多个相似签名Kotlin方法?

我正在使用这个库的一些代码: https : //github.com/Netflix-Skunkworks/rewrite 当我调用它的一个方法时,我遇到一个IDE错误: 所提供的参数都不能调用以下函数。 目标方法有两个相似的签名: 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 { val r = refactor() ops.accept(r) return r } } Kotlin的调用代码: val unit: CompilationUnit =… unit.refactor{ tx -> doSomeThing() } 在Java中,这个lambda调用是可以的: CompilationUnit […]