File tree 2 files changed +20
-5
lines changed
compiler/src/dotty/tools/dotc/transform 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -626,17 +626,20 @@ object Erasure extends TypeTestsCasts{
626
626
627
627
if (isRequired) {
628
628
// check for clashes
629
- val clash : Option [Symbol ] = oldSymbol.owner.info.decls.lookupAll(bridge.name).find {
630
- sym =>
631
- (sym.name eq bridge.name) && sym.info.widen =:= bridge.info.widen
632
- }.orElse(
629
+ val clash : Option [Symbol ] = oldSymbol.owner.info.memberExcluding(bridge.name, Flags .Bridge ).alternatives.find {
630
+ denot => {
631
+ ! denot.symbol.owner.is(Flags .Trait ) && // ignore traits, the clash will happen on their bridges.
632
+ (denot.symbol ne defn.Object_clone ) && // TODO: remove, only needed for legacy test: compileStdLib
633
+ ! denot.symbol.owner.derivesFrom(bridge.owner) && denot.symbol.info.widen =:= bridge.info.widen
634
+ }
635
+ }.map(_.symbol).orElse(
633
636
emittedBridges.find(stat => (stat.name == bridge.name) && stat.tpe.widen =:= bridge.info.widen)
634
637
.map(_.symbol))
635
638
clash match {
636
639
case Some (cl) =>
637
640
ctx.error(i " bridge for method ${newSymbol.showLocated(beforeCtx)} of type ${newSymbol.info(beforeCtx)}\n " +
638
641
i " clashes with ${cl.symbol.showLocated(beforeCtx)} of type ${cl.symbol.info(beforeCtx)}\n " +
639
- i " both have same type after erasure: ${bridge.symbol.info}" )
642
+ i " both have same type after erasure: ${bridge.symbol.info}" , newSymbol.pos )
640
643
case None => minimalSet += bridge
641
644
}
642
645
}
Original file line number Diff line number Diff line change
1
+
2
+ class A {
3
+ def compareTo (o : Any ): Int = 0
4
+ }
5
+ class B extends A with Comparable [B ] {
6
+ def compareTo (b : B ): Int = 0 // error
7
+ }
8
+ object C {
9
+ def main (args : Array [String ]): Unit = {
10
+ println(new B ().compareTo(new Object ()))
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments