From 7645024a9c17c24d0c2facbc76cc250512d4fa91 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 8 May 2015 18:05:36 +0200 Subject: 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. --- src/dotty/tools/dotc/typer/Applications.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Applications.scala') 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 -- cgit v1.2.3