Skip to content

Commit 585c47e

Browse files
committed
Implement PolyFunctionOf
1 parent 8b0e3af commit 585c47e

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,23 +384,20 @@ object QuotesAndSplices {
384384
super.transform(tree)
385385
end TreeMapWithVariance
386386

387-
// TODO-18271: Seems we can use PolyProto instead?
388387
object PolyFunctionOf {
389388
/**
390-
* Return a poly-type + function type [$typeargs] => ($args) => ($resultType)
389+
* Return a poly-type + method type [$typeargs] => ($args) => ($resultType)
391390
* where typeargs occur in args and resulttype
392-
*
393-
* @param typeargs
394-
* @param args
395-
* @param resultType
396-
* @return
397391
*/
398392
def apply(typeargs: List[Type], args: List[Type], resultType: Type)(using Context): Type =
399393
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)
394+
val paraminfosExp = (_: PolyType) => typeargs map (_.bounds)
395+
val resultTypeExp = (pt: PolyType) => {
396+
val fromSymbols = typeargs map (_.typeSymbol)
397+
val args1 = args map (_.subst(fromSymbols, pt.paramRefs))
398+
val resultType1 = resultType.subst(fromSymbols, pt.paramRefs)
399+
MethodType(args1, resultType)
400+
}
404401
val tpe = PolyType(typeargs1)(paraminfosExp, resultTypeExp)
405402
RefinedType(defn.PolyFunctionType, nme.apply, tpe)
406403
}

0 commit comments

Comments
 (0)