Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
7 changes: 5 additions & 2 deletions library/src/scala/internal/quoted/Matcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand All @@ -44,7 +44,7 @@ private[quoted] object Matcher {
}
}
else {
scrutineeTerm.underlyingArgument =?= patternTerm.underlyingArgument
scrutineeTerm =?= patternTerm
}
}

Expand Down Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions tests/run-macros/i6253-c/quoted_1.scala
Original file line number Diff line number Diff line change
@@ -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" }
}
}
}
10 changes: 10 additions & 0 deletions tests/run-macros/i6253-c/quoted_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Macros._

object Test {

def main(args: Array[String]): Unit = {
println(xyz"Hello World")
println(xyz"Hello ${"World"}")
}

}