I often run into this delegation case that doesn't compile:
class Foo: Bar by bar {
val bar: Bar = ...
}
This would get
Unresolved reference: bar
. Is there any reasoning for this other than the order in which the compiler is evaluating symbols? Could the compiler be improved so that it understands that
bar
exists, and generates the proper delegation code?
override fun doBar() = bar.doBar()
I'd also like to see the ability to delegate by method instead of by entire interface, something like:
override fun doBar() by bar
with specifying the arguments being optional, otherwise all possible overloads are delegated.