J'utilise un code de cette bibliothèque: https://github.com/Netflix-Skunkworks/rewriteComment appeler la méthode Kotlin avec plus d'une signature similaire avec lambda?
Quand j'appelle une de ses méthodes, je rencontre une erreur IDE:
None of the following functions can be called with the arguments supplied.
La méthode cible a deux signatures similaires:
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
}
}
Le code d'appel dans Kotlin:
val unit: CompilationUnit =...
unit.refactor{ tx ->
doSomeThing()
}
Et cet appel avec lambda est OK en Java:
CompilationUnit unit = ....
unit.refactor(tx -> {
doSomeThing()
});