Skip to content

Commit f676de2

Browse files
authored
Merge pull request #80 from scala/backport-lts-3.3-21677
Backport "Do not warn about expected missing positions in quotes.reflect.Symbol" to 3.3 LTS
2 parents b35033d + 1d5e3c5 commit f676de2

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2617,9 +2617,10 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
26172617
if self.exists then
26182618
val symPos = self.sourcePos
26192619
if symPos.exists then Some(symPos)
2620-
else
2620+
else if self.source.exists then
26212621
if xCheckMacro then report.warning(s"Missing symbol position (defaulting to position 0): $self\nThis is a compiler bug. Please report it.")
26222622
Some(self.source.atSpan(dotc.util.Spans.Span(0)))
2623+
else None
26232624
else None
26242625

26252626
def docstring: Option[String] =

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)