Skip to content

Commit b7e907a

Browse files
Merge pull request #10851 from dotty-staging/fix-#10127
Fix #10127: Don't try to get tags after error
2 parents a02e06f + dd2a5d0 commit b7e907a

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,11 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
140140

141141
protected def transformSpliceType(body: Tree, splice: Select)(using Context): Tree = {
142142
val body1 = transform(body)(using spliceContext)
143-
val tagRef = getQuoteTypeTags.getTagRef(splice.qualifier.tpe.asInstanceOf[TermRef])
144-
ref(tagRef).withSpan(splice.span)
143+
if ctx.reporter.hasErrors then
144+
splice
145+
else
146+
val tagRef = getQuoteTypeTags.getTagRef(splice.qualifier.tpe.asInstanceOf[TermRef])
147+
ref(tagRef).withSpan(splice.span)
145148
}
146149

147150
/** Check that annotations do not contain quotes and and that splices are valid */

tests/neg-macros/i10127-a.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import scala.quoted._
2+
3+
object T {
4+
def impl[A](using t: Type[A])(using Quotes): Expr[Unit] = {
5+
Expr.summon[t.Underlying] // error
6+
'{}
7+
}
8+
}

tests/neg-macros/i10127-b.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import scala.quoted._
2+
3+
case class T(x: Type[_ <: Any])
4+
5+
object T {
6+
def impl[A](t: T)(using ctx: Quotes): Expr[Unit] = {
7+
Expr.summon[t.x.Underlying] // error // error
8+
'{}
9+
}
10+
}

tests/pos-macros/i10127.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import scala.quoted._
2+
3+
object T {
4+
def impl[A](using Type[A])(using Quotes): Expr[Unit] = {
5+
Expr.summon[A]
6+
'{}
7+
}
8+
}

0 commit comments

Comments
 (0)