@@ -120,21 +120,28 @@ trait QuotesAndSplices {
120
120
}
121
121
}
122
122
val typedTypeargs = tree.typeargs.map {
123
- case arg : untpd.Ident =>
124
- typedType(arg) // TODO-18271: Is this appropriate?
123
+ case typearg : untpd.Ident =>
124
+ val typedTypearg = typedType(typearg) // TODO-18271: Is this appropriate?
125
+ /* TODO-18271: Allow type bounds?
126
+ * (NOTE: Needs non-trivial extension to type system)
127
+ */
128
+ val bounds = ctx.gadt.fullBounds(typedTypearg.symbol)
129
+ if bounds != null && bounds != TypeBounds .empty then
130
+ report.error(" Type arguments to Open pattern are expected to have no bounds" , typearg.srcPos)
131
+ typedTypearg
125
132
case arg =>
126
133
report.error(" Open pattern expected an identifier" , arg.srcPos)
127
134
EmptyTree
128
135
}
129
136
for arg <- typedArgs if arg.symbol.is(Mutable ) do // TODO support these patterns. Possibly using scala.quoted.util.Var
130
137
report.error(" References to `var`s cannot be used in higher-order pattern" , arg.srcPos)
131
138
val argTypes = typedArgs.map(_.tpe.widenTermRefExpr)
132
- // TODO-18271: Does PolyProto work here as expected?
133
139
val patType = (tree.typeargs.isEmpty, tree.args.isEmpty) match
134
140
case (true , true ) => pt
135
- case (true , false ) => defn.FunctionOf (argTypes, pt)
136
- case (false , true ) => PolyFunctionOf (typedTypeargs.tpes, Nil , pt)
137
- case (false , false ) => PolyFunctionOf (typedTypeargs.tpes, argTypes, pt)
141
+ case (true , false ) =>
142
+ defn.FunctionOf (argTypes, pt)
143
+ case (false , _) =>
144
+ PolyFunctionOf (typedTypeargs.tpes, argTypes, pt)
138
145
139
146
val pat = typedPattern(tree.body, defn.QuotedExprClass .typeRef.appliedTo(patType))(using quotePatternSpliceContext)
140
147
val baseType = pat.tpe.baseType(defn.QuotedExprClass )
@@ -391,17 +398,13 @@ object QuotesAndSplices {
391
398
*/
392
399
def apply (typeargs : List [Type ], args : List [Type ], resultType : Type )(using Context ): Type =
393
400
val typeargs1 = PolyType .syntheticParamNames(typeargs.length)
394
- val bounds = typeargs map { tpe =>
395
- ctx.gadt.fullBounds(tpe.typeSymbol) match
396
- case b: TypeBounds => b
397
- case _ => TypeBounds .empty
398
- }
399
- println(s " bounds = ${bounds map (_.show)}" )
401
+
402
+ val bounds = typeargs map (_ => TypeBounds .empty)
400
403
val resultTypeExp = (pt : PolyType ) => {
401
404
val fromSymbols = typeargs map (_.typeSymbol)
402
405
val args1 = args map (_.subst(fromSymbols, pt.paramRefs))
403
406
val resultType1 = resultType.subst(fromSymbols, pt.paramRefs)
404
- MethodType (args1, resultType )
407
+ MethodType (args1, resultType1 )
405
408
}
406
409
val tpe = PolyType (typeargs1)(_ => bounds, resultTypeExp)
407
410
RefinedType (defn.PolyFunctionType , nme.apply, tpe)
0 commit comments