Skip to content

Various refactorings #12938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 5, 2021
Prev Previous commit
Next Next commit
Improve expected types for dependent functions
  • Loading branch information
odersky committed Jun 25, 2021
commit 1ceafdf13d9f1bc168c1bb7cea1b67fb806c6008
13 changes: 8 additions & 5 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1146,12 +1146,15 @@ class Typer extends Namer
// if expected result type is a wildcard, approximate from above.
// this can type the greatest set of admissible closures.
(pt1.argTypesLo.init, typeTree(interpolateWildcards(pt1.argTypesHi.last)))
case SAMType(sam @ MethodTpe(_, formals, restpe)) =>
case RefinedType(parent, nme.apply, mt @ MethodTpe(_, formals, restpe))
if defn.isNonRefinedFunction(parent) && formals.length == defaultArity =>
(formals, untpd.DependentTypeTree(syms => restpe.substParams(mt, syms.map(_.termRef))))
case SAMType(mt @ MethodTpe(_, formals, restpe)) =>
(formals,
if sam.isResultDependent then
untpd.DependentTypeTree(syms => restpe.substParams(sam, syms.map(_.termRef)))
else
typeTree(restpe))
if (mt.isResultDependent)
untpd.DependentTypeTree(syms => restpe.substParams(mt, syms.map(_.termRef)))
else
typeTree(restpe))
case _ =>
(List.tabulate(defaultArity)(alwaysWildcardType), untpd.TypeTree())
}
Expand Down