diff --git a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala index 342b8f844fe5..c9c96635d7c1 100644 --- a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala +++ b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala @@ -98,10 +98,14 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( case _: This => assert(checkSymLevel(tree.symbol, tree.tpe, tree.sourcePos).isEmpty) tree - case _: Ident => - checkSymLevel(tree.symbol, tree.tpe, tree.sourcePos) match { - case Some(tpRef) => tpRef - case _ => tree + case Ident(name) => + if (name == nme.WILDCARD) { + untpd.Ident(name).withType(checkType(tree.sourcePos).apply(tree.tpe)).withSpan(tree.span) + } else { + checkSymLevel(tree.symbol, tree.tpe, tree.sourcePos) match { + case Some(tpRef) => tpRef + case _ => tree + } } case _: TypeTree | _: AppliedTypeTree | _: Apply | _: TypeApply | _: UnApply | Select(_, OuterSelectName(_, _)) => tree.withType(checkTp(tree.tpe)) diff --git a/tests/run-macros/i6679.check b/tests/run-macros/i6679.check new file mode 100644 index 000000000000..7326d9603970 --- /dev/null +++ b/tests/run-macros/i6679.check @@ -0,0 +1 @@ +Ok diff --git a/tests/run-macros/i6679/Macro_1.scala b/tests/run-macros/i6679/Macro_1.scala new file mode 100644 index 000000000000..74087d709d1f --- /dev/null +++ b/tests/run-macros/i6679/Macro_1.scala @@ -0,0 +1,14 @@ +import scala.quoted._ + +def makeMatch[A: Type](head : Expr[A]) given (qctx : QuoteContext) : Expr[Unit] = { + import qctx.tasty._ + + val sacrifice = '{ $head match { case _ => ??? } } + sacrifice.unseal + + '{ println("Ok") } +} + +def mm(implicit qctx : QuoteContext) = makeMatch('{42}) + +inline def f = ${ mm } diff --git a/tests/run-macros/i6679/Test_2.scala b/tests/run-macros/i6679/Test_2.scala new file mode 100644 index 000000000000..89e8042dbbbf --- /dev/null +++ b/tests/run-macros/i6679/Test_2.scala @@ -0,0 +1,8 @@ +import scala.quoted._ + +object Test { + + def main(args: Array[String]): Unit = { + f + } +} \ No newline at end of file