aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Applications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-11-13 17:16:20 +0100
committerMartin Odersky <odersky@gmail.com>2014-11-13 17:16:20 +0100
commitb7e547c4c3b6c0c867eb2636671106da2994044c (patch)
tree90b18ecad344160240999ad5f6b4e443c826707d /src/dotty/tools/dotc/typer/Applications.scala
parentc7ed89d562e497e0ede2c79e29ab884eee169454 (diff)
downloaddotty-b7e547c4c3b6c0c867eb2636671106da2994044c.tar.gz
dotty-b7e547c4c3b6c0c867eb2636671106da2994044c.tar.bz2
dotty-b7e547c4c3b6c0c867eb2636671106da2994044c.zip
Fixes problem exhibited by ensuring.scala
Need to account for the possibility that function arguments are wrapped in braces.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index a237e7781..931acb4b5 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -915,6 +915,10 @@ trait Applications extends Compatibility { self: Typer =>
val candidates = pt match {
case pt @ FunProto(args, resultType, _) =>
val numArgs = args.length
+ val normArgs = args.mapConserve {
+ case Block(Nil, expr) => expr
+ case x => x
+ }
def sizeFits(alt: TermRef, tp: Type): Boolean = tp match {
case tp: PolyType => sizeFits(alt, tp.resultType)
@@ -933,22 +937,25 @@ trait Applications extends Compatibility { self: Typer =>
def narrowBySize(alts: List[TermRef]): List[TermRef] =
alts filter (alt => sizeFits(alt, alt.widen))
- def narrowByShapes(alts: List[TermRef]): List[TermRef] =
- if (args exists (_.isInstanceOf[untpd.Function]))
+ def narrowByShapes(alts: List[TermRef]): List[TermRef] = {
+ if (normArgs exists (_.isInstanceOf[untpd.Function]))
if (args exists (_.isInstanceOf[Trees.NamedArg[_]]))
narrowByTrees(alts, args map treeShape, resultType)
else
- narrowByTypes(alts, args map typeShape, resultType)
+ narrowByTypes(alts, normArgs map typeShape, resultType)
else
alts
+ }
def narrowByTrees(alts: List[TermRef], args: List[Tree], resultType: Type): List[TermRef] =
alts filter (isApplicable(_, targs, args, resultType))
val alts1 = narrowBySize(alts)
+ //ctx.log(i"narrowed by size: ${alts1.map(_.symbol.showDcl)}%, %")
if (isDetermined(alts1)) alts1
else {
val alts2 = narrowByShapes(alts1)
+ //ctx.log(i"narrowed by shape: ${alts1.map(_.symbol.showDcl)}%, %")
if (isDetermined(alts2)) alts2
else narrowByTrees(alts2, pt.typedArgs, resultType)
}