Skip to content

Commit 352e1de

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

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import scala.quoted.runtime.impl.printers.*
2525
import scala.reflect.TypeTest
2626
import dotty.tools.dotc.core.NameKinds.ExceptionBinderName
2727
import dotty.tools.dotc.transform.TreeChecker
28+
import dotty.tools.dotc.util.NoSource
2829

2930
object QuotesImpl {
3031

@@ -2688,9 +2689,10 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
26882689
if self.exists then
26892690
val symPos = self.sourcePos
26902691
if symPos.exists then Some(symPos)
2691-
else
2692+
else if self.source.exists then
26922693
if xCheckMacro then report.warning(s"Missing symbol position (defaulting to position 0): $self\nThis is a compiler bug. Please report it.")
26932694
Some(self.source.atSpan(dotc.util.Spans.Span(0)))
2695+
else None
26942696
else None
26952697

26962698
def docstring: Option[String] =

tests/neg-macros/i19842-a.check

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

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

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