Skip to content

Commit 2a5abf7

Browse files
committed
Merge pull request scala#2553 from paulp/issue/7486
SI-7486 regression in implicit resolution.
2 parents e927cbc + dd33e28 commit 2a5abf7

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/compiler/scala/tools/nsc/typechecker/Implicits.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -996,11 +996,15 @@ trait Implicits {
996996
if (divergence || DivergentImplicitRecovery.sym != null) {
997997
if (settings.Xdivergence211.value) DivergingImplicitExpansionError(tree, pt, DivergentImplicitRecovery.sym)(context)
998998
else throw DivergentImplicit
999-
} else invalidImplicits take 1 foreach { sym =>
1000-
def isSensibleAddendum = pt match {
999+
}
1000+
else if (invalidImplicits.nonEmpty) {
1001+
val sym = invalidImplicits.head
1002+
// We don't even dare look if errors are being buffered
1003+
// !sym.hasFlag(LOCKED) is a hail mary between SI-2206 and SI-7486
1004+
def isSensibleAddendum = !sym.hasFlag(LOCKED) && (pt match {
10011005
case Function1(_, out) => out <:< sym.tpe.finalResultType
10021006
case _ => pt <:< sym.tpe.finalResultType
1003-
}
1007+
})
10041008
// Don't pitch in with this theory unless it looks plausible that the
10051009
// implicit would have helped
10061010
setAddendum(pos, () =>

test/files/pos/t7486.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object Test{
2+
var locker = 0
3+
// remove implicit, or change to `locker = locker + 1` to make it compile.
4+
implicit val davyJones0 = {
5+
locker += 0
6+
0
7+
}
8+
}

0 commit comments

Comments
 (0)