@@ -1108,9 +1108,9 @@ trait Implicits { self: Typer =>
1108
1108
/** Find a unique best implicit reference */
1109
1109
def bestImplicit (contextual : Boolean ): SearchResult = {
1110
1110
ctx.searchHistory.recursiveRef(pt) match {
1111
- case Some ( ref) =>
1111
+ case ref : TermRef =>
1112
1112
SearchSuccess (tpd.ref(ref).withPos(pos.startPos), ref, 0 )(ctx.typerState)
1113
- case None =>
1113
+ case _ =>
1114
1114
val eligible =
1115
1115
if (contextual) ctx.implicits.eligible(wildProto)
1116
1116
else implicitScope(wildProto).eligible
@@ -1192,29 +1192,32 @@ abstract class SearchHistory { outer =>
1192
1192
loop(open, isByname(pt))
1193
1193
}
1194
1194
1195
- def recursiveRef (pt : Type )(implicit ctx : Context ): Option [ TermRef ] = {
1195
+ def recursiveRef (pt : Type )(implicit ctx : Context ): Type = {
1196
1196
val widePt = pt.widenExpr
1197
1197
1198
1198
refBynameImplicit(widePt).orElse {
1199
1199
val bynamePt = isByname(pt)
1200
- if (! byname && ! bynamePt) None
1200
+ if (! byname && ! bynamePt) NoType
1201
1201
else {
1202
1202
@ tailrec
1203
- def loop (ois : List [(Candidate , Type )], belowByname : Boolean ): Option [ Type ] = {
1203
+ def loop (ois : List [(Candidate , Type )], belowByname : Boolean ): Type = {
1204
1204
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
1206
1206
case (_, tp) :: tl => loop(tl, belowByname || isByname(tp))
1207
- case _ => None
1207
+ case _ => NoType
1208
1208
}
1209
1209
}
1210
1210
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
+ }
1212
1215
}
1213
1216
}
1214
1217
}
1215
1218
1216
1219
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)
1218
1221
def defineBynameImplicit (tpe : Type , result : SearchSuccess )(implicit ctx : Context ): SearchResult = root.defineBynameImplicit(tpe, result)
1219
1222
def emitDictionary (pos : Position , result : SearchResult )(implicit ctx : Context ): SearchResult = result
1220
1223
@@ -1244,8 +1247,8 @@ final class SearchRoot extends SearchHistory {
1244
1247
}
1245
1248
}
1246
1249
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 )
1249
1252
}
1250
1253
1251
1254
override def defineBynameImplicit (tpe : Type , result : SearchSuccess )(implicit ctx : Context ): SearchResult = {
0 commit comments