@@ -78,7 +78,9 @@ trait QuotesAndSplices {
78
78
if (ctx.mode.is(Mode .QuotedPattern )) spliceOwner(ctx.outer) else ctx.owner
79
79
val pat = typedPattern(tree.expr, defn.QuotedExprClass .typeRef.appliedTo(pt))(
80
80
spliceContext.retractMode(Mode .QuotedPattern ).withOwner(spliceOwner(ctx)))
81
- Splice (pat)
81
+ val baseType = pat.tpe.baseType(defn.QuotedExprClass )
82
+ val argType = if baseType != NoType then baseType.argTypesHi.head else defn.NothingType
83
+ ref(defn.InternalQuoted_exprSplice ).appliedToTypes(List (argType, defn.QuoteContextClass .typeRef)).appliedTo(pat)
82
84
}
83
85
else {
84
86
ctx.error(i " Type must be fully defined. \n Consider annotating the splice using a type ascription: \n ( $tree: XYZ). " , tree.expr.sourcePos)
@@ -205,11 +207,15 @@ trait QuotesAndSplices {
205
207
val freshTypeBindingsBuff = new mutable.ListBuffer [Tree ]
206
208
val typePatBuf = new mutable.ListBuffer [Tree ]
207
209
override def transform (tree : Tree )(implicit ctx : Context ) = tree match {
208
- case Typed (Splice ( pat), tpt) if ! tpt.tpe.derivesFrom(defn.RepeatedParamClass ) =>
210
+ case Typed (Apply (fn, pat :: Nil ), tpt) if fn.symbol == defn. InternalQuoted_exprSplice && ! tpt.tpe.derivesFrom(defn.RepeatedParamClass ) =>
209
211
val tpt1 = transform(tpt) // Transform type bindings
210
212
val exprTpt = AppliedTypeTree (TypeTree (defn.QuotedExprClass .typeRef), tpt1 :: Nil )
211
- transform(Splice (Typed (pat, exprTpt)))
212
- case Splice (pat) =>
213
+ val newSplice =
214
+ ref(defn.InternalQuoted_exprSplice )
215
+ .appliedToTypes(List (tpt1.tpe, defn.QuoteContextClass .typeRef))
216
+ .appliedTo(Typed (pat, exprTpt))
217
+ transform(newSplice)
218
+ case Apply (fn, pat :: Nil ) if fn.symbol == defn.InternalQuoted_exprSplice =>
213
219
try ref(defn.InternalQuoted_patternHole .termRef).appliedToType(tree.tpe).withSpan(tree.span)
214
220
finally {
215
221
val patType = pat.tpe.widen
0 commit comments