Skip to content

Commit b5842bb

Browse files
authored
Merge pull request #6923 from dotty-staging/i6816
Fix #6816: Deny methods with implicit members from tpd.applyOverloaded
2 parents d589c37 + 160436b commit b5842bb

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
@@ -1147,6 +1147,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
11471147
var allAlts = denot.alternatives
11481148
.map(denot => TermRef(receiver.tpe, denot.symbol))
11491149
.filter(tr => typeParamCount(tr) == targs.length)
1150+
.filter { _.widen match {
1151+
case MethodTpe(_, _, x: MethodType) => !x.isImplicitMethod
1152+
case _ => true
1153+
}}
11501154
if (targs.isEmpty) allAlts = allAlts.filterNot(_.widen.isInstanceOf[PolyType])
11511155
val alternatives = ctx.typer.resolveOverloaded(allAlts, proto)
11521156
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)