diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index 584a46ebec2a..7ad6424682ea 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -1234,12 +1234,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { override def inlineContext(call: Tree)(implicit ctx: Context): Context = { // We assume enclosingInlineds is already normalized, and only process the new call with the head. val oldIC = enclosingInlineds - val newIC = (call, oldIC) match { - case (t, t1 :: ts2) if t.isEmpty => - assert(!t1.isEmpty) - ts2 - case _ => call :: oldIC - } + + val newIC = + if call.isEmpty then + oldIC match + case t1 :: ts2 => ts2 + case _ => oldIC + else + call :: oldIC + ctx.fresh.setProperty(InlinedCalls, newIC) } diff --git a/library/src/scala/internal/quoted/Matcher.scala b/library/src/scala/internal/quoted/Matcher.scala index 9b788ae93354..b59382f12a82 100644 --- a/library/src/scala/internal/quoted/Matcher.scala +++ b/library/src/scala/internal/quoted/Matcher.scala @@ -33,7 +33,7 @@ private[quoted] object Matcher { if (hasTypeSplices) { val ctx: Context = internal.Context_GADT_setFreshGADTBounds(rootContext) given Context = ctx - val matchings = scrutineeTerm.underlyingArgument =?= patternTerm.underlyingArgument + val matchings = scrutineeTerm =?= patternTerm // After matching and doing all subtype checks, we have to approximate all the type bindings // that we have found and seal them in a quoted.Type matchings.asOptionOfTuple.map { tup => @@ -44,7 +44,7 @@ private[quoted] object Matcher { } } else { - scrutineeTerm.underlyingArgument =?= patternTerm.underlyingArgument + scrutineeTerm =?= patternTerm } } @@ -286,6 +286,9 @@ private[quoted] object Matcher { case (_, Annotated(tpt, _)) => scrutinee =?= tpt + case (NamedArg(name1, arg1), NamedArg(name2, arg2)) if name1 == name2 => + arg1 =?= arg2 + // No Match case _ => if (debug) diff --git a/tests/run-macros/i6253-c/quoted_1.scala b/tests/run-macros/i6253-c/quoted_1.scala new file mode 100644 index 000000000000..c7a4a08e3256 --- /dev/null +++ b/tests/run-macros/i6253-c/quoted_1.scala @@ -0,0 +1,17 @@ +import scala.quoted._ + + +object Macros { + + // Should be: inline def (inline self: StringContext) ... + inline def (self: => StringContext) xyz(args: => String*): String = ${impl('self, 'args)} + + private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = { + self match { + case '{ StringContext($parts: _*) } => // Should not match as the parameter is not marked as inlined + '{ ??? } + case _ => + '{ "Ok" } + } + } +} diff --git a/tests/run-macros/i6253-c/quoted_2.scala b/tests/run-macros/i6253-c/quoted_2.scala new file mode 100644 index 000000000000..2a85eca35e41 --- /dev/null +++ b/tests/run-macros/i6253-c/quoted_2.scala @@ -0,0 +1,10 @@ +import Macros._ + +object Test { + + def main(args: Array[String]): Unit = { + println(xyz"Hello World") + println(xyz"Hello ${"World"}") + } + +}