I had this (very simplified) code:
// In a generic lib
interface ISerializer {
//...
}
// In a project using this lib
class MySerializer : ISerializer {
fun writeMyBlock(name: String, exp: ISerializer.() -> Unit) {
//...
exp()
//...
}
}
Months later, in the generic lib, I simply add a method in my interface (unfortunately, I choose exp
as name):
// In a generic lib
interface ISerializer {
fun exp(vararg s: String) {
//...
}
}
Some of my projects are then silently buggy: The call to exp()
in writeMyBlock()
no longer calls the function parameter, but the interface method ISerializer.exp()
. No warnings nor compilation error.
Precedence of object method over local function parameters seems an issue, making the code unstable in large projects.