ScalaNullSafe
ScalaNullSafe copied to clipboard
Make macro work in place of anonymous function
The macro should work in the following situation:
case class A(b: B)
case class B(c: C)
case class C(d: D)
case class D(s: String)
def expectFunction[T](f: A => T): T = ...
expectFunction(?(_.b.c.d.s))
Current it works if you do:
expectFunction(a => ?(a.b.c.d.s))
but it would be nice to be able to use the simpler syntax
Could ? be an extension function instead? That would seemingly solve the lambda case as well, as expectFunction(_.b.c.d.s.?). I guess that may not be portable to Scala 2...
Hmmm that potentially could work for Scala 3, but I'd like to keep the syntax consistent between versions. I probably just have to dig a bit deeper into the AST of the anonymous function syntax