diff --git a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala index 724971d869f8..15d76b88a13f 100644 --- a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala +++ b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala @@ -140,8 +140,11 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( protected def transformSpliceType(body: Tree, splice: Select)(using Context): Tree = { val body1 = transform(body)(using spliceContext) - val tagRef = getQuoteTypeTags.getTagRef(splice.qualifier.tpe.asInstanceOf[TermRef]) - ref(tagRef).withSpan(splice.span) + if ctx.reporter.hasErrors then + splice + else + val tagRef = getQuoteTypeTags.getTagRef(splice.qualifier.tpe.asInstanceOf[TermRef]) + ref(tagRef).withSpan(splice.span) } /** Check that annotations do not contain quotes and and that splices are valid */ diff --git a/tests/neg-macros/i10127-a.scala b/tests/neg-macros/i10127-a.scala new file mode 100644 index 000000000000..c62dab8b7ac2 --- /dev/null +++ b/tests/neg-macros/i10127-a.scala @@ -0,0 +1,8 @@ +import scala.quoted._ + +object T { + def impl[A](using t: Type[A])(using Quotes): Expr[Unit] = { + Expr.summon[t.Underlying] // error + '{} + } +} \ No newline at end of file diff --git a/tests/neg-macros/i10127-b.scala b/tests/neg-macros/i10127-b.scala new file mode 100644 index 000000000000..8c69ea5444c1 --- /dev/null +++ b/tests/neg-macros/i10127-b.scala @@ -0,0 +1,10 @@ +import scala.quoted._ + +case class T(x: Type[_ <: Any]) + +object T { + def impl[A](t: T)(using ctx: Quotes): Expr[Unit] = { + Expr.summon[t.x.Underlying] // error // error + '{} + } +} \ No newline at end of file diff --git a/tests/pos-macros/i10127.scala b/tests/pos-macros/i10127.scala new file mode 100644 index 000000000000..ccd710728d21 --- /dev/null +++ b/tests/pos-macros/i10127.scala @@ -0,0 +1,8 @@ +import scala.quoted._ + +object T { + def impl[A](using Type[A])(using Quotes): Expr[Unit] = { + Expr.summon[A] + '{} + } +} \ No newline at end of file