@@ -833,12 +833,18 @@ class Typer extends Namer
833
833
case _ : WildcardType => untpd.TypeTree ()
834
834
case _ => untpd.TypeTree (tp)
835
835
}
836
+ def interpolateWildcards = new TypeMap {
837
+ def apply (t : Type ): Type = t match
838
+ case WildcardType (bounds : TypeBounds ) =>
839
+ newTypeVar(apply(bounds.orElse(TypeBounds .empty)).bounds)
840
+ case _ => mapOver(t)
841
+ }
836
842
pt.stripTypeVar.dealias match {
837
843
case pt1 if defn.isNonRefinedFunction(pt1) =>
838
844
// if expected parameter type(s) are wildcards, approximate from below.
839
845
// if expected result type is a wildcard, approximate from above.
840
846
// this can type the greatest set of admissible closures.
841
- (pt1.argTypesLo.init, typeTree(pt1.argTypesHi.last))
847
+ (pt1.argTypesLo.init, typeTree(interpolateWildcards( pt1.argTypesHi.last) ))
842
848
case SAMType (sam @ MethodTpe (_, formals, restpe)) =>
843
849
(formals,
844
850
if (sam.isResultDependent)
@@ -1898,7 +1904,6 @@ class Typer extends Namer
1898
1904
else tree1
1899
1905
}
1900
1906
1901
-
1902
1907
def typedAsFunction (tree : untpd.PostfixOp , pt : Type )(implicit ctx : Context ): Tree = {
1903
1908
val untpd .PostfixOp (qual, Ident (nme.WILDCARD )) = tree
1904
1909
val pt1 = if (defn.isFunctionType(pt)) pt else AnyFunctionProto
0 commit comments