@@ -823,6 +823,9 @@ trait Implicits { self: Typer =>
823823 SearchSuccess (generated1, ref, cand.level)(ctx.typerState)
824824 }}
825825
826+ /** Try to type-check implicit reference, after checking that this is not
827+ * a diverging search
828+ */
826829 def tryImplicit (cand : Candidate ): SearchResult = {
827830 val history = ctx.searchHistory nest wildProto
828831 if (history eq ctx.searchHistory)
@@ -831,10 +834,18 @@ trait Implicits { self: Typer =>
831834 typedImplicit(cand)(nestedContext().setNewTyperState().setSearchHistory(history))
832835 }
833836
837+ /** Compare previous success with reference and level to determine which one would be chosen, if
838+ * an implicit starting with the reference was found.
839+ */
834840 def compareCandidate (prev : SearchSuccess , ref : TermRef , level : Int ): Int =
835841 if (prev.ref eq ref) 0
836842 else ctx.typerState.test(compare(prev.ref, ref, prev.level, level)(nestedContext()))
837843
844+ /** 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.
848+ */
838849 def disambiguate (alt1 : SearchResult , alt2 : SearchSuccess ) = alt1 match {
839850 case alt1 : SearchSuccess =>
840851 def isNumeric (tp : Type ) = tp.typeSymbol.isNumericValueClass
0 commit comments