Skip to content

Commit 7ecdee6

Browse files
committed
Disable implicit search everywhere for disambiaguation
Previously, one disambiguation step missed that, whereas implicits were turned off everywhere else. # Conflicts: # compiler/src/dotty/tools/dotc/typer/Implicits.scala
1 parent bde6bf3 commit 7ecdee6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ trait Implicits:
12201220
assert(argument.isEmpty || argument.tpe.isValueType || argument.tpe.isInstanceOf[ExprType],
12211221
em"found: $argument: ${argument.tpe}, expected: $pt")
12221222

1223-
private def nestedContext() =
1223+
private def searchContext() =
12241224
ctx.fresh.setMode(ctx.mode &~ Mode.ImplicitsEnabled)
12251225

12261226
private def isCoherent = pt.isRef(defn.CanEqualClass)
@@ -1264,7 +1264,7 @@ trait Implicits:
12641264
else
12651265
val history = ctx.searchHistory.nest(cand, pt)
12661266
val typingCtx =
1267-
nestedContext().setNewTyperState().setFreshGADTBounds.setSearchHistory(history)
1267+
searchContext().setNewTyperState().setFreshGADTBounds.setSearchHistory(history)
12681268
val result = typedImplicit(cand, pt, argument, span)(using typingCtx)
12691269
result match
12701270
case res: SearchSuccess =>
@@ -1291,7 +1291,7 @@ trait Implicits:
12911291
def compareAlternatives(alt1: RefAndLevel, alt2: RefAndLevel): Int =
12921292
if alt1.ref eq alt2.ref then 0
12931293
else if alt1.level != alt2.level then alt1.level - alt2.level
1294-
else explore(compare(alt1.ref, alt2.ref))(using nestedContext())
1294+
else explore(compare(alt1.ref, alt2.ref))(using searchContext())
12951295

12961296
/** If `alt1` is also a search success, try to disambiguate as follows:
12971297
* - If alt2 is preferred over alt1, pick alt2, otherwise return an
@@ -1326,7 +1326,7 @@ trait Implicits:
13261326
else
13271327
ctx.typerState
13281328

1329-
diff = inContext(ctx.withTyperState(comparisonState)) {
1329+
diff = inContext(searchContext().withTyperState(comparisonState)) {
13301330
compare(ref1, ref2)
13311331
}
13321332
case _ =>

0 commit comments

Comments
 (0)