Skip to content

Commit ff9de66

Browse files
committed
Clean up control flow in level
1 parent 4bacc25 commit ff9de66

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,16 @@ object Implicits:
306306
* Scala2 mode, since we do not want to change the implicit disambiguation then.
307307
*/
308308
override val level: Int =
309+
def isSameOwner = irefCtx.owner eq outerImplicits.irefCtx.owner
310+
def isSameScope = irefCtx.scope eq outerImplicits.irefCtx.scope
311+
def isLazyImplicit = refs.head.implicitName.is(LazyImplicitName)
312+
309313
if outerImplicits == null then 1
310-
else if isImport && (irefCtx.owner eq outerImplicits.irefCtx.owner)
311-
|| migrateTo3(using irefCtx)
312-
|| (irefCtx.owner eq outerImplicits.irefCtx.owner)
313-
&& (irefCtx.scope eq outerImplicits.irefCtx.scope)
314-
&& !refs.head.implicitName.is(LazyImplicitName)
314+
else if migrateTo3(using irefCtx)
315+
|| isSameOwner && (isImport || isSameScope && !isLazyImplicit)
315316
then outerImplicits.level
316317
else outerImplicits.level + 1
318+
end level
317319

318320
/** Is this the outermost implicits? This is the case if it either the implicits
319321
* of NoContext, or the last one before it.

0 commit comments

Comments
 (0)