From 160436b3887a41214aca5b0d27e649c69964c1f4 Mon Sep 17 00:00:00 2001 From: Anatolii Date: Wed, 24 Jul 2019 14:05:36 +0200 Subject: [PATCH] Fix #6816: Deny methods with implicit members from tpd.applyOverloaded We cannot resolve implicit parameters outside Typer. Hence methods that require implicit parameters should not be considered. --- compiler/src/dotty/tools/dotc/ast/tpd.scala | 4 ++++ tests/run/i6816.scala | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/run/i6816.scala diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index 821095dde886..789b65e8d5a4 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -1149,6 +1149,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { var allAlts = denot.alternatives .map(denot => TermRef(receiver.tpe, denot.symbol)) .filter(tr => typeParamCount(tr) == targs.length) + .filter { _.widen match { + case MethodTpe(_, _, x: MethodType) => !x.isImplicitMethod + case _ => true + }} if (targs.isEmpty) allAlts = allAlts.filterNot(_.widen.isInstanceOf[PolyType]) val alternatives = ctx.typer.resolveOverloaded(allAlts, proto) assert(alternatives.size == 1, diff --git a/tests/run/i6816.scala b/tests/run/i6816.scala new file mode 100644 index 000000000000..26cf87093436 --- /dev/null +++ b/tests/run/i6816.scala @@ -0,0 +1,14 @@ +trait Bar +trait Foo { + def ==(that: Foo)(implicit b: Bar): Boolean = ??? +} + +case class FooCC(f: Foo) + +object Test { + def main(args: Array[String]): Unit = { + val foo1, foo2 = new Foo {} + assert(FooCC(foo1) == FooCC(foo1)) + assert(FooCC(foo1) != FooCC(foo2)) + } +} \ No newline at end of file