Skip to content

Commit a1d17e5

Browse files
committed
Reject incomplete implicit dictionaries
If any RHS of a recursive implicit dictionary (after pruning) is an EmptyTree, then this indicates that implicit search failed and we should report the overall search as a failure. Fixes scala/bug#11591.
1 parent e89bdde commit a1d17e5

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ trait Contexts { self: Analyzer =>
351351
}
352352

353353
val pruned = prune(List(result.tree), implicitDictionary.map(_._2), Nil)
354-
if(pruned.isEmpty) result
354+
if (pruned.isEmpty) result
355+
else if (pruned.exists(_._2 == EmptyTree)) SearchFailure
355356
else {
356357
val pos = result.tree.pos
357358
val (dictClassSym, dictClass0) = {

test/files/neg/t11591.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
byname-implicits-bug.scala:8: error: could not find implicit value for parameter e: Test.A
2+
implicitly[A]
3+
^
4+
one error found

test/files/neg/t11591.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object Test {
2+
class A
3+
class B
4+
5+
implicit def mkA(implicit b: => B): A = ???
6+
implicit def mkB(implicit a: A, i: Int): B = ???
7+
8+
implicitly[A]
9+
}

0 commit comments

Comments
 (0)