Skip to content

Commit 12fb39b

Browse files
committed
Clean up tryCandidate
1 parent 9d158e0 commit 12fb39b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,18 @@ object Implicits:
240240
else
241241
val nestedCtx = ctx.fresh.addMode(Mode.TypevarsMissContext)
242242
val candidates = new mutable.ListBuffer[Candidate]
243-
var extensionOnly = true
244-
245-
val tryCandidate = (ref: ImplicitRef) =>
243+
def tryCandidate(extensionOnly: Boolean)(ref: ImplicitRef) =
246244
var ckind = explore(candidateKind(ref.underlyingRef))(using nestedCtx)
247245
if extensionOnly then ckind &= Candidate.Extension
248246
if ckind != Candidate.None then
249247
candidates += Candidate(ref, ckind, level)
250248

251249
if considerExtension then
252-
companionRefs.foreach(tryCandidate)
253-
extensionOnly = false
254-
refs.foreach(tryCandidate)
250+
val tryExtension = tryCandidate(extensionOnly = true)
251+
companionRefs.foreach(tryExtension)
252+
if refs.nonEmpty then
253+
val tryGiven = tryCandidate(extensionOnly = false)
254+
refs.foreach(tryGiven)
255255
candidates.toList
256256
}
257257
}

0 commit comments

Comments
 (0)