Skip to content

Commit 5eeee54

Browse files
committed
Allow function prototypes to have wildcards.
1 parent 5d6c102 commit 5eeee54

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,10 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
582582

583583
private def decomposeProtoFunction(pt: Type, defaultArity: Int)(implicit ctx: Context): (List[Type], Type) = pt match {
584584
case _ if defn.isFunctionType(pt) =>
585-
(pt.dealias.argInfos.init, pt.dealias.argInfos.last)
585+
// if expected parameter type(s) are wildcards, approximate from below.
586+
// if expected result type is a wildcard, approximate from above.
587+
// this can type the greatest set of admissible closures.
588+
(pt.dealias.argTypesLo.init, pt.dealias.argTypesHi.last)
586589
case SAMType(meth) =>
587590
val mt @ MethodType(_, paramTypes) = meth.info
588591
(paramTypes, mt.resultType)

0 commit comments

Comments
 (0)