scala/scala3

Deprecation warning generated via macro points to nonsense position

Closed this issue · 1 comments

Compiler version

any

Minimized code

Run with -deprecation

import scala.quoted._

@deprecated object A
object Test {
  inline def test() = ${testImpl}
  def testImpl(using Quotes): Expr[Any] =
    import quotes.reflect._
    Ref(Symbol.classSymbol("A$").companionModule).asExpr
}
@main def main() =
  Test.test()

Output

-- Deprecation Warning: depr2.scala:4:46 ---------------------------------------
4 |
  |                                              ^^^^^^^^^^^
  |                                              object A is deprecated

Expectation

Point the warning to the callsite., message could also probably be improved

The span from the inlined bit is used, which is wrong.

That is corrected in the PR, but improving the message and/or representation of inlined code is still research.