Closed
Description
Compiler version
3.0.1-RC1-bin-20210407-8b35b67-NIGHTLY
Minimized code
class Foo(val strings: Seq[String]) extends FooLowPriority
trait FooLowPriority { self: Foo =>
@scala.annotation.targetName("appendFromProducers")
def append(v: String): Foo = new Foo(v +: self.strings)
}
trait FooBar { self: Foo =>
@scala.annotation.targetName("appendFromProducers")
final override def append(v: String): Foo = new Foo(self.strings :+ v)
}
object Foo {
type Bar = Foo with FooBar
def bar(vs: String*): Bar = new Foo(vs) with FooBar
}
Foo.bar("foo").append("bar") // Throw runtime exception
Output
Compile without error, but running the final call throw the following Exception
Caused by: java.lang.IncompatibleClassChangeError: Conflicting default methods: test/FooLowPriority.appendFromProducers test/FooBar.appendFromProducers
at Foo$$anon$1.appendFromProducers(..)
Without @targetName
, it runs fine.
With plain inheritance/no mixin, it runs files:
class Foo(val strings: Seq[String]) extends FooLowPriority
trait FooLowPriority { self: Foo =>
@scala.annotation.targetName("appendFromProducers")
def append(v: String): Foo = new Foo(v +: self.strings)
}
class FooBar(strings: Seq[String]) extends Foo(strings) {
@scala.annotation.targetName("appendFromProducers")
final override def append(v: String): Foo = new Foo(strings :+ v)
}
object Foo {
def bar(vs: String*): FooBar = new FooBar(vs)
}
Expectation
Compile and run without error