Skip to content

Commit 160436b

Browse files
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.
1 parent eb12c21 commit 160436b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
11491149
var allAlts = denot.alternatives
11501150
.map(denot => TermRef(receiver.tpe, denot.symbol))
11511151
.filter(tr => typeParamCount(tr) == targs.length)
1152+
.filter { _.widen match {
1153+
case MethodTpe(_, _, x: MethodType) => !x.isImplicitMethod
1154+
case _ => true
1155+
}}
11521156
if (targs.isEmpty) allAlts = allAlts.filterNot(_.widen.isInstanceOf[PolyType])
11531157
val alternatives = ctx.typer.resolveOverloaded(allAlts, proto)
11541158
assert(alternatives.size == 1,

tests/run/i6816.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
trait Bar
2+
trait Foo {
3+
def ==(that: Foo)(implicit b: Bar): Boolean = ???
4+
}
5+
6+
case class FooCC(f: Foo)
7+
8+
object Test {
9+
def main(args: Array[String]): Unit = {
10+
val foo1, foo2 = new Foo {}
11+
assert(FooCC(foo1) == FooCC(foo1))
12+
assert(FooCC(foo1) != FooCC(foo2))
13+
}
14+
}

0 commit comments

Comments
 (0)