@@ -915,6 +915,10 @@ trait Applications extends Compatibility { self: Typer =>
915
915
val candidates = pt match {
916
916
case pt @ FunProto (args, resultType, _) =>
917
917
val numArgs = args.length
918
+ val normArgs = args.mapConserve {
919
+ case Block (Nil , expr) => expr
920
+ case x => x
921
+ }
918
922
919
923
def sizeFits (alt : TermRef , tp : Type ): Boolean = tp match {
920
924
case tp : PolyType => sizeFits(alt, tp.resultType)
@@ -933,22 +937,25 @@ trait Applications extends Compatibility { self: Typer =>
933
937
def narrowBySize (alts : List [TermRef ]): List [TermRef ] =
934
938
alts filter (alt => sizeFits(alt, alt.widen))
935
939
936
- def narrowByShapes (alts : List [TermRef ]): List [TermRef ] =
937
- if (args exists (_.isInstanceOf [untpd.Function ]))
940
+ def narrowByShapes (alts : List [TermRef ]): List [TermRef ] = {
941
+ if (normArgs exists (_.isInstanceOf [untpd.Function ]))
938
942
if (args exists (_.isInstanceOf [Trees .NamedArg [_]]))
939
943
narrowByTrees(alts, args map treeShape, resultType)
940
944
else
941
- narrowByTypes(alts, args map typeShape, resultType)
945
+ narrowByTypes(alts, normArgs map typeShape, resultType)
942
946
else
943
947
alts
948
+ }
944
949
945
950
def narrowByTrees (alts : List [TermRef ], args : List [Tree ], resultType : Type ): List [TermRef ] =
946
951
alts filter (isApplicable(_, targs, args, resultType))
947
952
948
953
val alts1 = narrowBySize(alts)
954
+ // ctx.log(i"narrowed by size: ${alts1.map(_.symbol.showDcl)}%, %")
949
955
if (isDetermined(alts1)) alts1
950
956
else {
951
957
val alts2 = narrowByShapes(alts1)
958
+ // ctx.log(i"narrowed by shape: ${alts1.map(_.symbol.showDcl)}%, %")
952
959
if (isDetermined(alts2)) alts2
953
960
else narrowByTrees(alts2, pt.typedArgs, resultType)
954
961
}
0 commit comments