Skip to content

Commit 3b66be1

Browse files
committed
Don't look at nesting for implicit resolution under Scala2 mode.
1 parent f6fb4ec commit 3b66be1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,14 @@ object Implicits {
144144
class ContextualImplicits(val refs: List[TermRef], val outerImplicits: ContextualImplicits)(initctx: Context) extends ImplicitRefs(initctx) {
145145
private val eligibleCache = new mutable.AnyRefMap[Type, List[Candidate]]
146146

147+
/** The level increases if current context has a different owner or scope than
148+
* the context of the next-outer ImplicitRefs. This is however disabled under
149+
* Scala2 mode, since we do not want to change the implicit disambiguation then.
150+
*/
147151
override val level: Int =
148152
if (outerImplicits == null) 1
149-
else if ((ctx.owner eq outerImplicits.ctx.owner) &&
153+
else if (ctx.scala2Mode ||
154+
(ctx.owner eq outerImplicits.ctx.owner) &&
150155
(ctx.scope eq outerImplicits.ctx.scope)) outerImplicits.level
151156
else outerImplicits.level + 1
152157

0 commit comments

Comments
 (0)