Skip to content

Commit b5341a5

Browse files
committed
Extend typedSplicePattern with type arguments
1 parent a28b1ce commit b5341a5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,13 @@ trait QuotesAndSplices {
130130
for arg <- typedArgs if arg.symbol.is(Mutable) do // TODO support these patterns. Possibly using scala.quoted.util.Var
131131
report.error("References to `var`s cannot be used in higher-order pattern", arg.srcPos)
132132
val argTypes = typedArgs.map(_.tpe.widenTermRefExpr)
133-
// TODO-18271: Generate polyType if typedTypeargs is not empty
134-
val patType = if tree.args.isEmpty then pt else defn.FunctionOf(argTypes, pt)
133+
// TODO-18271: Does PolyProto work here as expected?
134+
val patType = (tree.typeargs.isEmpty, tree.args.isEmpty) match
135+
case (false, false) => pt
136+
case (false, true) => defn.FunctionOf(argTypes, pt)
137+
case (true, false) => ProtoTypes.PolyProto(typedTypeargs, pt)
138+
case (true, true) => ProtoTypes.PolyProto(typedTypeargs, defn.FunctionOf(argTypes, pt))
139+
135140
val pat = typedPattern(tree.body, defn.QuotedExprClass.typeRef.appliedTo(patType))(using quotePatternSpliceContext)
136141
val baseType = pat.tpe.baseType(defn.QuotedExprClass)
137142
val argType = if baseType.exists then baseType.argTypesHi.head else defn.NothingType

0 commit comments

Comments
 (0)