Skip to content

Wrong position on an extension method call #10011

Closed
@adpi2

Description

@adpi2

Minimized code

I have a macro method that prints the location of the expression that is passed to it:

inline def printPos[T](inline expr: T): Unit =
  ${ printPos('expr) }

private def printPos[T](expr: Expr[T])(using QuoteContext): Expr[Unit] =
  '{ println( ${Expr(expr.unseal.pos.toString) } ) }

Then I can pass a call to an extension method to it:

extension [T](a: T) def foo: Any = ???

@main def Test = printPos(Some(1).foo)

Output

It prints /home/adpi2/test/src/main/scala/App.scala:<81..88> which corresponds to Some(1)

Expectation

The position should contain Some(1).foo

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions