@@ -53,7 +53,7 @@ trait QuotesAndSplices {
53
53
ctx.error(em " Quotes require stable QuoteContext, but found non stable $qctx" , qctx.sourcePos)
54
54
55
55
val tree1 =
56
- if ctx.mode.is(Mode .Pattern ) && level == 0 then
56
+ if ctx.mode.is(Mode .Pattern ) then
57
57
typedQuotePattern(tree, pt, qctx)
58
58
else if (tree.quoted.isType)
59
59
typedTypeApply(untpd.TypeApply (untpd.ref(defn.InternalQuoted_typeQuote .termRef), tree.quoted :: Nil ), pt)(using quoteContext)
@@ -72,7 +72,7 @@ trait QuotesAndSplices {
72
72
ctx.warning(" Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ." , tree.sourcePos)
73
73
case _ =>
74
74
}
75
- if (ctx.mode.is(Mode .QuotedPattern ) && level == 1 )
75
+ if (ctx.mode.is(Mode .QuotedPattern ))
76
76
if (isFullyDefined(pt, ForceDegree .all)) {
77
77
def spliceOwner (ctx : Context ): Symbol =
78
78
if (ctx.mode.is(Mode .QuotedPattern )) spliceOwner(ctx.outer) else ctx.owner
@@ -99,24 +99,10 @@ trait QuotesAndSplices {
99
99
100
100
val (outerQctx, ctx1) = popQuoteContext()
101
101
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
-
116
102
val internalSplice =
117
103
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)
120
106
121
107
typedApply(internalSplice, pt)(using ctx1).withSpan(tree.span)
122
108
}
0 commit comments