Skip to content

Commit 51e645f

Browse files
committed
Add PolyFunctionOf (maybe not necessarry)
1 parent b5341a5 commit 51e645f

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
@@ -383,4 +383,25 @@ object QuotesAndSplices {
383383
case _ =>
384384
super.transform(tree)
385385
end TreeMapWithVariance
386+
387+
// TODO-18271: Seems we can use PolyProto instead?
388+
object PolyFunctionOf {
389+
/**
390+
* Return a poly-type + function type [$typeargs] => ($args) => ($resultType)
391+
* where typeargs occur in args and resulttype
392+
*
393+
* @param typeargs
394+
* @param args
395+
* @param resultType
396+
* @return
397+
*/
398+
def apply(typeargs: List[Type], args: List[Type], resultType: Type)(using Context): Type =
399+
val typeargs1 = PolyType.syntheticParamNames(typeargs.length)
400+
// TODO-18271 What would be good bounds?
401+
val paraminfosExp = (_: PolyType) => typeargs map (_ => TypeBounds.empty)
402+
// TODO-18271 Replace type args occurence in args with typeargs1?
403+
val resultTypeExp = (_: PolyType) => defn.FunctionOf(args, resultType)
404+
val tpe = PolyType(typeargs1)(paraminfosExp, resultTypeExp)
405+
RefinedType(defn.PolyFunctionType, nme.apply, tpe)
406+
}
386407
}

0 commit comments

Comments
 (0)