Currently, constructs like Foo ?=> (Bar, Baz) => Qux causes two function objects be allocated on heap. This may be especially costly on repeated invocations, as there is no way to cache second function. Usually, performance-sensitive spots are highly specialized, so someone might want to replace such declaration with a specialized trait:
trait FooFunction {
def apply(using Foo)(a: Bar, b: Baz): Qux
}
However, currently it doesn't work as expected:
object Meow extends App {
trait FooFunc {
def apply(using Foo)(b: Bar): Unit
}
val f: FooFunc = b => println(s"bar=$b, foo=${summon[Foo]}")
// error: expected Bar => Unit, got Unit
}
Feature request is to unify behavior of such SAM lambdas with currently present behavior of context functions.