Skip to content

Commit caac72a

Browse files
committed
Do not warn about expected missing positions in quotes reflect.Symbols.pos
1 parent 4ae5d61 commit caac72a

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Diff for: compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -2698,9 +2698,10 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
26982698
if self.exists then
26992699
val symPos = self.sourcePos
27002700
if symPos.exists then Some(symPos)
2701-
else
2701+
else if self.source.exists then
27022702
if xCheckMacro then report.warning(s"Missing symbol position (defaulting to position 0): $self\nThis is a compiler bug. Please report it.")
27032703
Some(self.source.atSpan(dotc.util.Spans.Span(0)))
2704+
else None
27042705
else None
27052706

27062707
def docstring: Option[String] =

Diff for: tests/pos-macros/i21672/Macro_1.scala

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object Repro {
2+
inline def apply(): Unit = ${ applyImpl }
3+
4+
import scala.quoted.*
5+
def applyImpl(using q: Quotes): Expr[Unit] = {
6+
import q.reflect.*
7+
report.info(TypeRepr.of[Some[String]].typeSymbol.pos.toString)
8+
'{ () }
9+
}
10+
}

Diff for: tests/pos-macros/i21672/Test_2.scala

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//> using options -Xfatal-warnings
2+
object Test:
3+
Repro()

0 commit comments

Comments
 (0)