Skip to content

Commit a310c92

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

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
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/neg-macros/i19842-a.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
|
1010
| at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
1111
| at dotty.tools.dotc.transform.TreeChecker$.checkParents(TreeChecker.scala:210)
12+
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:258)
1213
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:257)
13-
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:256)
1414
| at Macros$.makeSerializer(Macro.scala:25)
1515
|
1616
|---------------------------------------------------------------------------------------------------------------------

tests/neg-macros/i19842-b.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
|
1010
| at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
1111
| at dotty.tools.dotc.transform.TreeChecker$.checkParents(TreeChecker.scala:210)
12+
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:258)
1213
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:257)
13-
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:256)
1414
| at Macros$.makeSerializer(Macro.scala:27)
1515
|
1616
|---------------------------------------------------------------------------------------------------------------------

tests/pos-macros/i21672/Macro_1.scala

Lines changed: 10 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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)