From d8299501aebfd971605597e5b12d55e2281e994b Mon Sep 17 00:00:00 2001 From: Miles Sabin Date: Wed, 3 Jul 2019 15:02:09 +0100 Subject: [PATCH] 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 --- compiler/src/dotty/tools/dotc/typer/Implicits.scala | 1 + tests/neg/i6796.scala | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/neg/i6796.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index 42caa2a3f7e8..2bf9f176028b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -1842,6 +1842,7 @@ final class SearchRoot extends SearchHistory { val pruned = prune(List(tree), implicitDictionary.map(_._2).toList, Nil) implicitDictionary0 = null if (pruned.isEmpty) result + else if (pruned.exists(_._2 == EmptyTree)) NoMatchingImplicitsFailure else { // If there are any dictionary entries remaining after pruning, construct a dictionary // class of the form, diff --git a/tests/neg/i6796.scala b/tests/neg/i6796.scala new file mode 100644 index 000000000000..3888d5f33f1f --- /dev/null +++ b/tests/neg/i6796.scala @@ -0,0 +1,10 @@ +object Test { + class A + class B + + implicit def mkA(implicit b: => B): A = ??? + implicit def mkB(implicit a: A, i: Int): B = ??? + + implicitly[A] // error +} +