Skip to content

Commit c1670ce

Browse files
committed
Refactor dependent function refinement logic
1 parent 4b1adef commit c1670ce

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,16 +1320,15 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
13201320
case tp: TypeParamRef =>
13211321
decomposeProtoFunction(ctx.typerState.constraint.entry(tp).bounds.hi, defaultArity, pos)
13221322
case _ => pt1.findFunctionType match {
1323-
case pt1 if defn.isNonRefinedFunction(pt1) =>
1323+
case ft if defn.isNonRefinedFunction(ft) =>
13241324
// if expected parameter type(s) are wildcards, approximate from below.
13251325
// if expected result type is a wildcard, approximate from above.
13261326
// this can type the greatest set of admissible closures.
13271327

1328-
(pt1.argInfos.init, typeTree(interpolateWildcards(pt1.argInfos.last.hiBound)))
1329-
case RefinedType(parent, nme.apply, mt @ MethodTpe(_, formals, restpe))
1330-
if defn.isNonRefinedFunction(parent) && formals.length == defaultArity =>
1331-
(formals, untpd.InLambdaTypeTree(isResult = true, (_, syms) => restpe.substParams(mt, syms.map(_.termRef))))
1332-
case defn.PolyFunctionOf(mt @ MethodTpe(_, formals, restpe)) if formals.length == defaultArity =>
1328+
(ft.argInfos.init, typeTree(interpolateWildcards(ft.argInfos.last.hiBound)))
1329+
case ft @ RefinedType(parent, nme.apply, mt @ MethodTpe(_, formals, restpe))
1330+
if defn.isFunctionType(ft) && formals.length == defaultArity =>
1331+
// PolyFunction or dependent refinement
13331332
(formals, untpd.InLambdaTypeTree(isResult = true, (_, syms) => restpe.substParams(mt, syms.map(_.termRef))))
13341333
case SAMType(mt @ MethodTpe(_, formals, _), samParent) =>
13351334
val restpe = mt.resultType match

0 commit comments

Comments
 (0)