diff --git a/tests/run/i12032.check b/tests/run/i12032.check new file mode 100644 index 000000000000..3bd1f0e29744 --- /dev/null +++ b/tests/run/i12032.check @@ -0,0 +1,2 @@ +foo +bar diff --git a/tests/run/i12032.scala b/tests/run/i12032.scala new file mode 100644 index 000000000000..52358332e2c8 --- /dev/null +++ b/tests/run/i12032.scala @@ -0,0 +1,24 @@ +// https://github.com/lampepfl/dotty/issues/12032 +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 +} + +@main def Test() = + Foo.bar("foo") + .append("bar") + .strings + .foreach(println)