Skip to content

Commit bf9063f

Browse files
committed
Add PolyFunctionOf (maybe not necessarry)
1 parent 14c6594 commit bf9063f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,25 @@ object QuotesAndSplices {
367367
case _ =>
368368
super.transform(tree)
369369
end TreeMapWithVariance
370+
371+
// TODO-18271: Seems we can use PolyProto instead?
372+
object PolyFunctionOf {
373+
/**
374+
* Return a poly-type + function type [$typeargs] => ($args) => ($resultType)
375+
* where typeargs occur in args and resulttype
376+
*
377+
* @param typeargs
378+
* @param args
379+
* @param resultType
380+
* @return
381+
*/
382+
def apply(typeargs: List[Type], args: List[Type], resultType: Type)(using Context): Type =
383+
val typeargs1 = PolyType.syntheticParamNames(typeargs.length)
384+
// TODO-18271 What would be good bounds?
385+
val paraminfosExp = (_: PolyType) => typeargs map (_ => TypeBounds.empty)
386+
// TODO-18271 Replace type args occurence in args with typeargs1?
387+
val resultTypeExp = (_: PolyType) => defn.FunctionOf(args, resultType)
388+
val tpe = PolyType(typeargs1)(paraminfosExp, resultTypeExp)
389+
RefinedType(defn.PolyFunctionType, nme.apply, tpe)
390+
}
370391
}

0 commit comments

Comments
 (0)