aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Applications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-05-08 18:05:36 +0200
committerMartin Odersky <odersky@gmail.com>2015-05-08 18:05:43 +0200
commit7645024a9c17c24d0c2facbc76cc250512d4fa91 (patch)
tree4c78255f998f071924047bd6be0e0c5064c77b21 /src/dotty/tools/dotc/typer/Applications.scala
parent905c541ba39f667f8b08fae85cb875470e283492 (diff)
downloaddotty-7645024a9c17c24d0c2facbc76cc250512d4fa91.tar.gz
dotty-7645024a9c17c24d0c2facbc76cc250512d4fa91.tar.bz2
dotty-7645024a9c17c24d0c2facbc76cc250512d4fa91.zip
Fix #547: Vararg overload
When comparing to types in isAsSpecific, onvert repeated parameters to their underlying type only if both types are vararg methods. This mimics scalac behavior.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index fec6482b8..6ea91f512 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -849,7 +849,10 @@ trait Applications extends Compatibility { self: Typer =>
case tp @ ExprType(tp1) => tp.derivedExprType(repeatedToSingle(tp1))
case _ => if (tp.isRepeatedParam) tp.argTypesHi.head else tp
}
- isApplicable(alt2, tp1.paramTypes map repeatedToSingle, WildcardType) ||
+ val formals1 =
+ if (tp1.isVarArgsMethod && tp2.isVarArgsMethod) tp1.paramTypes map repeatedToSingle
+ else tp1.paramTypes
+ isApplicable(alt2, formals1, WildcardType) ||
tp1.paramTypes.isEmpty && tp2.isInstanceOf[MethodOrPoly]
case _ =>
tp2 match {
@@ -878,7 +881,7 @@ trait Applications extends Compatibility { self: Typer =>
def winsOwner2 = isDerived(owner2, owner1)
def winsType2 = isAsSpecific(alt2, tp2, alt1, tp1)
- implicits.println(i"isAsGood($alt1, $alt2)? $tp1 $tp2 $winsOwner1 $winsType1 $winsOwner2 $winsType2")
+ overload.println(i"isAsGood($alt1, $alt2)? $tp1 $tp2 $winsOwner1 $winsType1 $winsOwner2 $winsType2")
// Assume the following probabilities:
//
@@ -1013,6 +1016,7 @@ trait Applications extends Compatibility { self: Typer =>
if (isDetermined(candidates)) candidates
else narrowMostSpecific(candidates) match {
case result @ (alt1 :: alt2 :: _) =>
+// overload.println(i"ambiguous $alt1 $alt2")
val deepPt = pt.deepenProto
if (deepPt ne pt) resolveOverloaded(alts, deepPt, targs)
else result