From 5eeee54e1a1419edf40efb9f9928076a143e7cd7 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 19 Jul 2016 17:27:20 +0200 Subject: Allow function prototypes to have wildcards. --- src/dotty/tools/dotc/typer/Typer.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 11a7b6753..df72f0095 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -582,7 +582,10 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit private def decomposeProtoFunction(pt: Type, defaultArity: Int)(implicit ctx: Context): (List[Type], Type) = pt match { case _ if defn.isFunctionType(pt) => - (pt.dealias.argInfos.init, pt.dealias.argInfos.last) + // if expected parameter type(s) are wildcards, approximate from below. + // if expected result type is a wildcard, approximate from above. + // this can type the greatest set of admissible closures. + (pt.dealias.argTypesLo.init, pt.dealias.argTypesHi.last) case SAMType(meth) => val mt @ MethodType(_, paramTypes) = meth.info (paramTypes, mt.resultType) -- cgit v1.2.3