@@ -45,10 +45,16 @@ trait QuotesAndSplices {
45
45
ctx.warning(" Canceled splice directly inside a quote. '[ ${ XYZ } ] is equivalent to XYZ." , tree.sourcePos)
46
46
case _ =>
47
47
}
48
+ val qctx = inferImplicitArg(defn.QuoteContextClass .typeRef, tree.span)
49
+ if (level == 0 && qctx.tpe.isInstanceOf [SearchFailureType ])
50
+ ctx.error(missingArgMsg(qctx, defn.QuoteContextClass .typeRef, " " ), ctx.source.atSpan(tree.span))
48
51
val tree1 =
49
- if (ctx.mode.is(Mode .Pattern ) && level == 0 ) typedQuotePattern(tree, pt)
50
- else if (tree.quoted.isType) typedTypeApply(untpd.TypeApply (untpd.ref(defn.InternalQuoted_typeQuote .termRef), tree.quoted :: Nil ), pt)(quoteContext)
51
- else typedApply(untpd.Apply (untpd.ref(defn.InternalQuoted_exprQuote .termRef), tree.quoted), pt)(quoteContext)
52
+ if ctx.mode.is(Mode .Pattern ) && level == 0 then
53
+ typedQuotePattern(tree, pt, qctx)
54
+ else if (tree.quoted.isType)
55
+ typedTypeApply(untpd.TypeApply (untpd.ref(defn.InternalQuoted_typeQuote .termRef), tree.quoted :: Nil ), pt)(quoteContext)
56
+ else
57
+ typedApply(untpd.Apply (untpd.ref(defn.InternalQuoted_exprQuote .termRef), tree.quoted), pt)(quoteContext).select(nme.apply).appliedTo(qctx)
52
58
tree1.withSpan(tree.span)
53
59
}
54
60
@@ -326,11 +332,7 @@ trait QuotesAndSplices {
326
332
* ) => ...
327
333
* ```
328
334
*/
329
- private def typedQuotePattern (tree : untpd.Quote , pt : Type )(implicit ctx : Context ): Tree = {
330
- val qctx = inferImplicitArg(defn.QuoteContextClass .typeRef, tree.span)
331
- if (level == 0 && qctx.tpe.isInstanceOf [SearchFailureType ])
332
- ctx.error(missingArgMsg(qctx, defn.QuoteContextClass .typeRef, " " ), ctx.source.atSpan(tree.span))
333
-
335
+ private def typedQuotePattern (tree : untpd.Quote , pt : Type , qctx : Tree )(implicit ctx : Context ): Tree = {
334
336
val quoted = tree.quoted
335
337
val exprPt = pt.baseType(if quoted.isType then defn.QuotedTypeClass else defn.QuotedExprClass )
336
338
val quotedPt = exprPt.argInfos.headOption match {
0 commit comments