@@ -841,28 +841,34 @@ trait Implicits { self: Typer =>
841841 if (prev.ref eq ref) 0
842842 else ctx.typerState.test(compare(prev.ref, ref, prev.level, level)(nestedContext()))
843843
844+ /* Seems we don't need this anymore.
845+ def numericValueTieBreak(alt1: SearchSuccess, alt2: SearchSuccess) = {
846+ def isNumeric(tp: Type) = tp.typeSymbol.isNumericValueClass
847+ def isProperSubType(tp1: Type, tp2: Type) =
848+ tp1.isValueSubType(tp2) && !tp2.isValueSubType(tp1)
849+ val rpt = pt.resultType
850+ val rt1 = alt1.ref.widen.resultType
851+ val rt2 = alt2.ref.widen.resultType
852+ if (isNumeric(rpt) && isNumeric(rt1) && isNumeric(rt2))
853+ if (isProperSubType(rt1, rt2)) alt2
854+ else if (isProperSubType(rt2, rt1)) alt1
855+ else NoMatchingImplicitsFailure
856+ else NoMatchingImplicitsFailure
857+ }
858+ */
859+
844860 /** If `alt1` is also a search success, try to disambiguate as follows:
845- * - If alt2 is preferred over alt1, pick alt2.
846- * - Otherwise, if both alternatives return numeric value types, pick the one
847- * with the larger type.
861+ * - If alt2 is preferred over alt1, pick alt2, otherwise return an
862+ * ambiguous implicits error.
848863 */
849864 def disambiguate (alt1 : SearchResult , alt2 : SearchSuccess ) = alt1 match {
850865 case alt1 : SearchSuccess =>
851- def isNumeric (tp : Type ) = tp.typeSymbol.isNumericValueClass
852- def isProperSubType (tp1 : Type , tp2 : Type ) =
853- tp1.isValueSubType(tp2) && ! tp2.isValueSubType(tp1)
854- val rpt = pt.resultType
855- val rt1 = alt1.ref.widen.resultType
856- val rt2 = alt2.ref.widen.resultType
857- def ambi = SearchFailure (new AmbiguousImplicits (alt1, alt2, pt, argument))
858866 val diff = compareCandidate(alt1, alt2.ref, alt2.level)
859867 assert(diff <= 0 )
860868 if (diff < 0 ) alt2
861- else if (isNumeric(rpt) && isNumeric(rt1) && isNumeric(rt2))
862- if (isProperSubType(rt1, rt2)) alt2
863- else if (isProperSubType(rt2, rt1)) alt1
864- else ambi
865- else ambi
869+ else
870+ // numericValueTypeBreak(alt1, alt2) recoverWith
871+ SearchFailure (new AmbiguousImplicits (alt1, alt2, pt, argument))
866872 case _ : SearchFailure => alt2
867873 }
868874
0 commit comments