|
1 | 1 | class Foo |
2 | 2 |
|
3 | | -// Using self-types to force mixin forwarders |
4 | | - |
5 | | -trait OneA[X] { |
| 3 | +trait One[X] { |
6 | 4 | def concat(suffix: Int): X = ??? |
7 | 5 | } |
8 | 6 |
|
9 | | -trait OneB[X] { self: OneA[X] => |
10 | | - override def concat(suffix: Int): X = ??? |
11 | | -} |
12 | | - |
13 | | -trait TwoA[Y/* <: Foo*/] { |
| 7 | +trait Two[Y/* <: Foo*/] { |
14 | 8 | def concat[Dummy](suffix: Int): Y = ??? |
15 | 9 | } |
16 | 10 |
|
17 | | -trait TwoB[Y/* <: Foo*/] { self: TwoA[Y] => |
18 | | - override def concat[Dummy](suffix: Int): Y = ??? |
19 | | -} |
20 | | - |
21 | | -class Bar1 extends OneA[Foo] with OneB[Foo] |
| 11 | +class Bar1 extends One[Foo] |
22 | 12 | // Because mixin forwarders are generated after erasure, we get: |
23 | 13 | // override def concat(suffix: Int): Object |
24 | 14 |
|
25 | | -class Bar2 extends Bar1 with TwoA[Foo] with TwoB[Foo] // error |
26 | | - // We get a mixin forwarder for TwoB: |
| 15 | +class Bar2 extends Bar1 with Two[Foo] // error |
| 16 | + // We get a mixin forwarder for Two: |
27 | 17 | // override def concat(suffix: Int): Object |
28 | 18 | // This clashes with the forwarder generated in Bar1, and the compiler detects that: |
29 | 19 | // |
30 | | - // |class Bar2 extends Bar1 with TwoA[Foo] with TwoB[Foo] |
| 20 | + // |class Bar2 extends Bar1 with Two[Foo] |
31 | 21 | // | ^ |
32 | | - // | Name clash between inherited members: |
33 | | - // | override def concat(suffix: Int): Object in trait OneB at line 10 and |
34 | | - // | override def concat: [Dummy](suffix: Int): Y in trait TwoB at line 18 |
35 | | - // | have the same type after erasure. |
| 22 | + // | Name clash between inherited members: |
| 23 | + // | def concat(suffix: Int): X in trait One at line 4 and |
| 24 | + // | def concat: [Dummy](suffix: Int): Y in trait Two at line 8 |
| 25 | + // | have the same type after erasure. |
36 | 26 | // |
37 | 27 | // This also works with separate compilation as demonstrated by |
38 | 28 | // mixin-forwarder-clash2. |
0 commit comments