aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/Implicits.scala
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/Implicits.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Implicits.scala7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala
index 79cab8b74..331533204 100644
--- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala
@@ -144,9 +144,14 @@ object Implicits {
class ContextualImplicits(val refs: List[TermRef], val outerImplicits: ContextualImplicits)(initctx: Context) extends ImplicitRefs(initctx) {
private val eligibleCache = new mutable.AnyRefMap[Type, List[Candidate]]
+ /** The level increases if current context has a different owner or scope than
+ * the context of the next-outer ImplicitRefs. This is however disabled under
+ * Scala2 mode, since we do not want to change the implicit disambiguation then.
+ */
override val level: Int =
if (outerImplicits == null) 1
- else if ((ctx.owner eq outerImplicits.ctx.owner) &&
+ else if (ctx.scala2Mode ||
+ (ctx.owner eq outerImplicits.ctx.owner) &&
(ctx.scope eq outerImplicits.ctx.scope)) outerImplicits.level
else outerImplicits.level + 1