Skip to content

Commit 9af70bd

Browse files
committed
Do not warn about expected missing positions in quotes reflect.Symbols.pos
1 parent ac28899 commit 9af70bd

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -2688,9 +2688,10 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
26882688
if self.exists then
26892689
val symPos = self.sourcePos
26902690
if symPos.exists then Some(symPos)
2691-
else
2691+
else if self.source.exists then
26922692
if xCheckMacro then report.warning(s"Missing symbol position (defaulting to position 0): $self\nThis is a compiler bug. Please report it.")
26932693
Some(self.source.atSpan(dotc.util.Spans.Span(0)))
2694+
else None
26942695
else None
26952696

26962697
def docstring: Option[String] =

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+
}

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)