@@ -166,6 +166,32 @@ trait QuotesAndSplices {
166
166
typedSplicePattern(untpd.cpy.SplicePattern (tree)(splice.body, Nil , args), pt)
167
167
}
168
168
169
+ /** Types a splice applied to some type arguments and arguments
170
+ * `$f[targs1, ..., targsn](arg1, ..., argn)` in a quote pattern.
171
+ *
172
+ * TODO-18217: Remove follwing notes on complete
173
+ * Refer to: typedTypeApply
174
+ */
175
+ def typedAppliedSpliceWithTypes (tree : untpd.Apply , pt : Type )(using Context ): Tree = {
176
+ assert(ctx.mode.is(Mode .QuotedPattern ))
177
+ val untpd .Apply (typeApplyTree @ untpd.TypeApply (splice : untpd.SplicePattern , typeargs), args) = tree : @ unchecked
178
+ def isInBraces : Boolean = splice.span.end != splice.body.span.end
179
+ if isInBraces then // ${x}[...](...) match an application
180
+ // TODO-18127: typedTypeApply cares about named arguments. Do we want to care as well?
181
+ val typedTypeargs = typeargs.map(arg => typedType(arg))
182
+ // TODO-18217: Why do we use typedExpr here?
183
+ val typedArgs = args.map(arg => typedExpr(arg))
184
+ val argTypes = typedArgs.map(_.tpe.widenTermRefExpr)
185
+ val splice1 = typedSplicePattern(splice, ProtoTypes .PolyProto (typedArgs, defn.FunctionOf (argTypes, pt)))
186
+ val typedTypeApply = untpd.cpy.TypeApply (typeApplyTree)(splice1.select(nme.apply), typedTypeargs)
187
+ untpd.cpy.Apply (tree)(typedTypeApply, typedArgs).withType(pt)
188
+ else // $x(...) higher-order quasipattern
189
+ // TODO-18271: Case for highr-order quasi-quote pattern with type params
190
+ if typeargs.isEmpty || args.isEmpty then
191
+ report.error(" Missing arguments for open pattern" , tree.srcPos)
192
+ typedSplicePattern(untpd.cpy.SplicePattern (tree)(splice.body, typeargs, args), pt)
193
+ }
194
+
169
195
/** Type check a type binding reference in a quoted pattern.
170
196
*
171
197
* If no binding exists with that name, this becomes the definition of a new type binding.
0 commit comments