Inspecting method application when materializing context parameter

I already asked this on Discord (link), but haven’t found a solution so I figured I would ask here as well. This also is more discoverable for posterity.

I am wondering if it is possible with inline macro expansion to get the position of the calling function. For example given a macro of the shape:

case class SourceLocator(file: String, line: Int, column: Int)
object SourceLocator {
  inline given SourceLocator =  ${ SourceLocatorMacro.materialize }
}

SourceLocatorMacro.materialize is implemented using Position.ofMacroExpansion. And library code of the shape:

class Bool {
  def &&(that: Bool)(using SourceLocator): Bool = ...
  def :=(rhs: Bool)(using SourceLocator): Unit = ...
}

Now given user code:

val a, b, c, d = new Bool
d := a && b && c

This works, but the column information points to the end of the arguments (e.g. locator for a && b points to b, the locator for := points to c). What I want is to point to the operator itself. Now, I have found that I can accomplish this by having the using clause first, e.g.

class Bool {
  def &&(using SourceLocator): Bool = ...
  def :=(using SourceLocator)(rhs: Bool): Unit = ...
}

This works, and is probably what I have to do. The main problem with it is that I think it makes it harder to read the code and API docs, especially for my users who are typically not Scala experts. (using SourceLocator) is about as many characters as the important part of the definition: def &&(that: Bool): Bool. So splitting the useful part in half with this chunk of text is noise I’d like to avoid.

Is it possible in materializing a given to see a little bit more of the context so I can get the Position of the function application? For example, Symbol.spliceOwner makes it possible to see things like the name of a val bound to the result of the larger expression, but I want to look at the expression itself.

Assuming having the using parameter list first is the only way to solve this, I did write a ScalaFix rule to help ensure code follows the style: GitHub - jackkoenig/move-context-parameter