Skip to content

Commit 4cb35ef

Browse files
committed
Merge pull request #225 from dotty-staging/fix/ensuring
Fixes problem exhibited by ensuring.scala
2 parents c7ed89d + b7e547c commit 4cb35ef

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ object Reporter {
4545

4646
override def toString = s"$getClass at $pos: $msg"
4747
override def getMessage() = msg
48+
49+
def checkingStr: String = msgFn
4850
}
4951

5052
class Error(msgFn: => String, pos: SourcePosition) extends Diagnostic(msgFn, pos, ERROR)

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,10 @@ trait Applications extends Compatibility { self: Typer =>
915915
val candidates = pt match {
916916
case pt @ FunProto(args, resultType, _) =>
917917
val numArgs = args.length
918+
val normArgs = args.mapConserve {
919+
case Block(Nil, expr) => expr
920+
case x => x
921+
}
918922

919923
def sizeFits(alt: TermRef, tp: Type): Boolean = tp match {
920924
case tp: PolyType => sizeFits(alt, tp.resultType)
@@ -933,22 +937,25 @@ trait Applications extends Compatibility { self: Typer =>
933937
def narrowBySize(alts: List[TermRef]): List[TermRef] =
934938
alts filter (alt => sizeFits(alt, alt.widen))
935939

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]))
938942
if (args exists (_.isInstanceOf[Trees.NamedArg[_]]))
939943
narrowByTrees(alts, args map treeShape, resultType)
940944
else
941-
narrowByTypes(alts, args map typeShape, resultType)
945+
narrowByTypes(alts, normArgs map typeShape, resultType)
942946
else
943947
alts
948+
}
944949

945950
def narrowByTrees(alts: List[TermRef], args: List[Tree], resultType: Type): List[TermRef] =
946951
alts filter (isApplicable(_, targs, args, resultType))
947952

948953
val alts1 = narrowBySize(alts)
954+
//ctx.log(i"narrowed by size: ${alts1.map(_.symbol.showDcl)}%, %")
949955
if (isDetermined(alts1)) alts1
950956
else {
951957
val alts2 = narrowByShapes(alts1)
958+
//ctx.log(i"narrowed by shape: ${alts1.map(_.symbol.showDcl)}%, %")
952959
if (isDetermined(alts2)) alts2
953960
else narrowByTrees(alts2, pt.typedArgs, resultType)
954961
}
File renamed without changes.

0 commit comments

Comments
 (0)