scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.83k stars 1.05k forks source link

Position of Some type generates warning #21672

Open MateuszKubuszok opened 6 days ago

MateuszKubuszok commented 6 days ago

Compiler version

3.3.4

Minimized code

//> using scala 3.3.4
//> using option -Xcheck-macros
//> using test.dep org.scalameta::munit:1.0.2

object Repro {

  inline def apply(): Unit = ${ applyImpl }

  import scala.quoted.*
  def applyImpl(using q: Quotes): Expr[Unit] = {
   import q.*, q.reflect.*
   report.info(TypeRepr.of[Some[String]].typeSymbol.pos.toString)
   '{ () }
  }
}
class Test extends munit.FunSuite {

  test("sdfsdf") {
    Repro()
  }
}

Output

[warn] ./test.test.scala:4:5
[warn] Missing symbol position (defaulting to position 0): class Some
[warn] This is a compiler bug. Please report it.
[warn]     Repro()
[warn]     ^^^^^^^

Expectation

No warning.

This might be troublesome for macro libraries with -Xcheck-macros and -Xfatal-warnings.

The bug might be older than 3.3.4, since 3.3.4 just added the check, 3.3.3 might have the same issue but there was no check for it.

jchyb commented 6 days ago

Anyone having this issue might want to use something like: -Wconf:msg=Missing.symbol.position:s to silence those until 3.3.5. For others that happened upon this issue, if your symbol/tree which ends up throwing this warning comes from the currently compiled codebase, please also consider submitting your minimization, as the fix for that might be different