Skip to content

Commit b123253

Browse files
committed
Improve expected types for dependent functions
1 parent f674c18 commit b123253

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,10 +1132,13 @@ class Typer extends Namer
11321132
// if expected result type is a wildcard, approximate from above.
11331133
// this can type the greatest set of admissible closures.
11341134
(pt1.argTypesLo.init, typeTree(interpolateWildcards(pt1.argTypesHi.last)))
1135-
case SAMType(sam @ MethodTpe(_, formals, restpe)) =>
1135+
case RefinedType(parent, nme.apply, mt @ MethodTpe(_, formals, restpe))
1136+
if defn.isNonRefinedFunction(parent) && formals.length == defaultArity =>
1137+
(formals, untpd.DependentTypeTree(syms => restpe.substParams(mt, syms.map(_.termRef))))
1138+
case SAMType(mt @ MethodTpe(_, formals, restpe)) =>
11361139
(formals,
1137-
if (sam.isResultDependent)
1138-
untpd.DependentTypeTree(syms => restpe.substParams(sam, syms.map(_.termRef)))
1140+
if (mt.isResultDependent)
1141+
untpd.DependentTypeTree(syms => restpe.substParams(mt, syms.map(_.termRef)))
11391142
else
11401143
typeTree(restpe))
11411144
case tp: TypeParamRef =>

0 commit comments

Comments
 (0)