@@ -78,7 +78,9 @@ trait QuotesAndSplices {
7878 if (ctx.mode.is(Mode .QuotedPattern )) spliceOwner(ctx.outer) else ctx.owner
7979 val pat = typedPattern(tree.expr, defn.QuotedExprClass .typeRef.appliedTo(pt))(
8080 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)
8284 }
8385 else {
8486 ctx.error(i " Type must be fully defined. \n Consider annotating the splice using a type ascription: \n ( $tree: XYZ). " , tree.expr.sourcePos)
@@ -208,7 +210,11 @@ trait QuotesAndSplices {
208210 case Typed (Apply (fn, pat :: Nil ), tpt) if fn.symbol == defn.InternalQuoted_exprSplice && ! tpt.tpe.derivesFrom(defn.RepeatedParamClass ) =>
209211 val tpt1 = transform(tpt) // Transform type bindings
210212 val exprTpt = AppliedTypeTree (TypeTree (defn.QuotedExprClass .typeRef), tpt1 :: Nil )
211- transform(Splice (Typed (pat, exprTpt)))
213+ val newSplice =
214+ ref(defn.InternalQuoted_exprSplice )
215+ .appliedToTypes(List (tpt1.tpe, defn.QuoteContextClass .typeRef))
216+ .appliedTo(Typed (pat, exprTpt))
217+ transform(newSplice)
212218 case Apply (fn, pat :: Nil ) if fn.symbol == defn.InternalQuoted_exprSplice =>
213219 try ref(defn.InternalQuoted_patternHole .termRef).appliedToType(tree.tpe).withSpan(tree.span)
214220 finally {
0 commit comments