but this can work for overriding any member function to explicitly change its behavior whenever a receiver is in context. I would wager that this isn't surprising to the user of a library because they explicitly opt-in by bringing a receiver in scope.Could this ever be a kotlin feature or am I dreaming too much lol?
won't be a user-accessible annotation neever. It was introduces in language to cover one specific corner case in kotlin/java stdlib parity (to hide
and resolve to kotlin extension insted)The main problem with
is performance: when compiler tries to resolve some function call, it looks for such function in several scopes and stops when it find good function in one of them. Member functions have high priority, and compiler looks here at the first place (and usually it stops here, because users quite frequently call members). But if
exists than compiler need to look in every scope for each call, because there might be some extension with this annotation, which will incredibly decrease resolution time. Resolution is the most performance heavy part and even with current lazy algorithm (stop of first found function) it takes ~60% of all frontend time