diff --git a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala index 7a57b67d7f6a..007d49116757 100644 --- a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala +++ b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala @@ -73,7 +73,7 @@ trait QuotesAndSplices { case _ => } if (ctx.mode.is(Mode.QuotedPattern)) - if (isFullyDefined(pt, ForceDegree.all)) { + if (isFullyDefined(pt, ForceDegree.flipBottom)) { def spliceOwner(ctx: Context): Symbol = if (ctx.mode.is(Mode.QuotedPattern)) spliceOwner(ctx.outer) else ctx.owner val pat = typedPattern(tree.expr, defn.QuotedExprClass.typeRef.appliedTo(pt))( diff --git a/tests/run-macros/quote-matcher-inference/Macro_1.scala b/tests/run-macros/quote-matcher-inference/Macro_1.scala new file mode 100644 index 000000000000..743e6b9cd452 --- /dev/null +++ b/tests/run-macros/quote-matcher-inference/Macro_1.scala @@ -0,0 +1,15 @@ +import scala.quoted._ + + +object Macros { + + inline def g(inline x: Unit): Unit = ${impl('x)} + + private def impl(x: Expr[Any])(using QuoteContext): Expr[Any] = { + x match + case '{ println(f($y)) } => y + } + +} + +def f[T](x: T): T = x diff --git a/tests/run-macros/quote-matcher-inference/Test_2.scala b/tests/run-macros/quote-matcher-inference/Test_2.scala new file mode 100644 index 000000000000..327112a64868 --- /dev/null +++ b/tests/run-macros/quote-matcher-inference/Test_2.scala @@ -0,0 +1,10 @@ +import Macros._ + + +object Test { + + def main(args: Array[String]): Unit = { + g(println(f((5)))) + } + +}