Skip to content

Commit

Permalink
Reject incomplete implicit dictionaries
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
milessabin committed Jul 3, 2019
1 parent e89bdde commit a1d17e5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/compiler/scala/tools/nsc/typechecker/Contexts.scala
Expand Up @@ -351,7 +351,8 @@ trait Contexts { self: Analyzer =>
}

val pruned = prune(List(result.tree), implicitDictionary.map(_._2), Nil)
if(pruned.isEmpty) result
if (pruned.isEmpty) result
else if (pruned.exists(_._2 == EmptyTree)) SearchFailure
else {
val pos = result.tree.pos
val (dictClassSym, dictClass0) = {
Expand Down
4 changes: 4 additions & 0 deletions test/files/neg/t11591.check
@@ -0,0 +1,4 @@
byname-implicits-bug.scala:8: error: could not find implicit value for parameter e: Test.A
implicitly[A]
^
one error found
9 changes: 9 additions & 0 deletions test/files/neg/t11591.scala
@@ -0,0 +1,9 @@
object Test {
class A
class B

implicit def mkA(implicit b: => B): A = ???
implicit def mkB(implicit a: A, i: Int): B = ???

implicitly[A]
}

0 comments on commit a1d17e5

Please sign in to comment.