Skip to content

Commit d829950

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 #6796
1 parent ea57e36 commit d829950

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,7 @@ final class SearchRoot extends SearchHistory {
18421842
val pruned = prune(List(tree), implicitDictionary.map(_._2).toList, Nil)
18431843
implicitDictionary0 = null
18441844
if (pruned.isEmpty) result
1845+
else if (pruned.exists(_._2 == EmptyTree)) NoMatchingImplicitsFailure
18451846
else {
18461847
// If there are any dictionary entries remaining after pruning, construct a dictionary
18471848
// class of the form,

tests/neg/i6796.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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] // error
9+
}
10+

0 commit comments

Comments
 (0)