@@ -53,7 +53,7 @@ trait QuotesAndSplices {
5353 ctx.error(em " Quotes require stable QuoteContext, but found non stable $qctx" , qctx.sourcePos)
5454
5555 val tree1 =
56- if ctx.mode.is(Mode .Pattern ) && level == 0 then
56+ if ctx.mode.is(Mode .Pattern ) then
5757 typedQuotePattern(tree, pt, qctx)
5858 else if (tree.quoted.isType)
5959 typedTypeApply(untpd.TypeApply (untpd.ref(defn.InternalQuoted_typeQuote .termRef), tree.quoted :: Nil ), pt)(using quoteContext)
@@ -72,7 +72,7 @@ trait QuotesAndSplices {
7272 ctx.warning(" Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ." , tree.sourcePos)
7373 case _ =>
7474 }
75- if (ctx.mode.is(Mode .QuotedPattern ) && level == 1 )
75+ if (ctx.mode.is(Mode .QuotedPattern ))
7676 if (isFullyDefined(pt, ForceDegree .all)) {
7777 def spliceOwner (ctx : Context ): Symbol =
7878 if (ctx.mode.is(Mode .QuotedPattern )) spliceOwner(ctx.outer) else ctx.owner
@@ -99,24 +99,10 @@ trait QuotesAndSplices {
9999
100100 val (outerQctx, ctx1) = popQuoteContext()
101101
102- // Explicitly provide the given QuoteContext of the splice.
103- // * Avoids leaking implementation details of scala.internal.quoted.CompileTime.exprSplice,
104- // such as exprSplice taking a ?=> function argument
105- // * Provide meaningful names for QuoteContext synthesized by within `${ ... }`
106- // * If within a quote, provide a QuoteContext is linked typewise with the outer QuoteContext
107- val qctxParamName = NameKinds .UniqueName .fresh(s " qctx ${if level > 0 then level - 1 else " " }_ " .toTermName)
108- val qctxParamTpe = outerQctx match {
109- case Some (qctxRef) => qctxRef.tpe.select(" NestedContext" .toTypeName)
110- case _ => defn.QuoteContextClass .typeRef // splice at level 0 (or lower)
111- }
112- val qctxParamTpt = untpd.TypedSplice (TypeTree (qctxParamTpe))
113- val qctxParam = untpd.makeParameter(qctxParamName, qctxParamTpt, untpd.Modifiers (Given ))
114- val expr = untpd.Function (List (qctxParam), tree.expr).withSpan(tree.span)
115-
116102 val internalSplice =
117103 outerQctx match
118- case Some (qctxRef) => untpd.Apply (untpd.Apply (untpd.ref(defn.InternalQuoted_exprNestedSplice .termRef), qctxRef), expr)
119- case _ => untpd.Apply (untpd.ref(defn.InternalQuoted_exprSplice .termRef), expr)
104+ case Some (qctxRef) => untpd.Apply (untpd.Apply (untpd.ref(defn.InternalQuoted_exprNestedSplice .termRef), qctxRef), tree. expr)
105+ case _ => untpd.Apply (untpd.ref(defn.InternalQuoted_exprSplice .termRef), tree. expr)
120106
121107 typedApply(internalSplice, pt)(using ctx1).withSpan(tree.span)
122108 }
0 commit comments