@@ -1108,9 +1108,9 @@ trait Implicits { self: Typer =>
11081108 /** Find a unique best implicit reference */
11091109 def bestImplicit (contextual : Boolean ): SearchResult = {
11101110 ctx.searchHistory.recursiveRef(pt) match {
1111- case Some ( ref) =>
1111+ case ref : TermRef =>
11121112 SearchSuccess (tpd.ref(ref).withPos(pos.startPos), ref, 0 )(ctx.typerState)
1113- case None =>
1113+ case _ =>
11141114 val eligible =
11151115 if (contextual) ctx.implicits.eligible(wildProto)
11161116 else implicitScope(wildProto).eligible
@@ -1192,29 +1192,32 @@ abstract class SearchHistory { outer =>
11921192 loop(open, isByname(pt))
11931193 }
11941194
1195- def recursiveRef (pt : Type )(implicit ctx : Context ): Option [ TermRef ] = {
1195+ def recursiveRef (pt : Type )(implicit ctx : Context ): Type = {
11961196 val widePt = pt.widenExpr
11971197
11981198 refBynameImplicit(widePt).orElse {
11991199 val bynamePt = isByname(pt)
1200- if (! byname && ! bynamePt) None
1200+ if (! byname && ! bynamePt) NoType
12011201 else {
12021202 @ tailrec
1203- def loop (ois : List [(Candidate , Type )], belowByname : Boolean ): Option [ Type ] = {
1203+ def loop (ois : List [(Candidate , Type )], belowByname : Boolean ): Type = {
12041204 ois match {
1205- case (hd@ (cand, tp)) :: tl if (belowByname || isByname(tp)) && tp.widenExpr <:< widePt => Some (tp)
1205+ case (hd@ (cand, tp)) :: tl if (belowByname || isByname(tp)) && tp.widenExpr <:< widePt => tp
12061206 case (_, tp) :: tl => loop(tl, belowByname || isByname(tp))
1207- case _ => None
1207+ case _ => NoType
12081208 }
12091209 }
12101210
1211- loop(open, bynamePt).map(tp => ctx.searchHistory.linkBynameImplicit(tp.widenExpr))
1211+ loop(open, bynamePt) match {
1212+ case NoType => NoType
1213+ case tp => ctx.searchHistory.linkBynameImplicit(tp.widenExpr)
1214+ }
12121215 }
12131216 }
12141217 }
12151218
12161219 def linkBynameImplicit (tpe : Type )(implicit ctx : Context ): TermRef = root.linkBynameImplicit(tpe)
1217- def refBynameImplicit (tpe : Type )(implicit ctx : Context ): Option [ TermRef ] = root.refBynameImplicit(tpe)
1220+ def refBynameImplicit (tpe : Type )(implicit ctx : Context ): Type = root.refBynameImplicit(tpe)
12181221 def defineBynameImplicit (tpe : Type , result : SearchSuccess )(implicit ctx : Context ): SearchResult = root.defineBynameImplicit(tpe, result)
12191222 def emitDictionary (pos : Position , result : SearchResult )(implicit ctx : Context ): SearchResult = result
12201223
@@ -1244,8 +1247,8 @@ final class SearchRoot extends SearchHistory {
12441247 }
12451248 }
12461249
1247- override def refBynameImplicit (tpe : Type )(implicit ctx : Context ): Option [ TermRef ] = {
1248- implicitDictionary.get(tpe).map(_._1)
1250+ override def refBynameImplicit (tpe : Type )(implicit ctx : Context ): Type = {
1251+ implicitDictionary.get(tpe).map(_._1).getOrElse( NoType )
12491252 }
12501253
12511254 override def defineBynameImplicit (tpe : Type , result : SearchSuccess )(implicit ctx : Context ): SearchResult = {
0 commit comments