Commit dec6cc6
committed
Fix #8599: Emit trait init methods only as static methods.
Concrete trait methods are encoded as two methods in the back-end:
* a default method containing the real body, and
* a static forwarder, to use for super calls (due to JVM reasons).
Previously, we did that also for the trait initializer methods
`$init$`. However, that causes unrelated default methods to be
inherited by Scala classes that extend several traits. In turn,
that prevents Java classes from extending such classes.
Now, for the `$init$` methods, instead of creating a static
forwarder, we *move* the entire body to a static method. Therefore,
we only create a static method, and no default method.
This corresponds to what scalac does as well (both what we do and
how we do it), although the previous "discrepancy" was not causing
any incompatibility between Scala 2 and 3 per se.1 parent 2efaeb0 commit dec6cc6
File tree
6 files changed
+87
-25
lines changed- compiler/src/dotty/tools/backend/jvm
- tests/run
- i8599
- junitForwarders
6 files changed
+87
-25
lines changedLines changed: 62 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
577 | 578 | | |
578 | 579 | | |
579 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
580 | 588 | | |
581 | 589 | | |
582 | 590 | | |
| |||
586 | 594 | | |
587 | 595 | | |
588 | 596 | | |
589 | | - | |
590 | | - | |
591 | | - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
592 | 604 | | |
593 | 605 | | |
594 | 606 | | |
| |||
629 | 641 | | |
630 | 642 | | |
631 | 643 | | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
632 | 680 | | |
633 | 681 | | |
634 | 682 | | |
| |||
646 | 694 | | |
647 | 695 | | |
648 | 696 | | |
649 | | - | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
650 | 706 | | |
651 | 707 | | |
652 | 708 | | |
653 | | - | |
| 709 | + | |
654 | 710 | | |
655 | 711 | | |
656 | 712 | | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
| 713 | + | |
663 | 714 | | |
664 | 715 | | |
665 | 716 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | 12 | | |
21 | 13 | | |
22 | 14 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
28 | 18 | | |
29 | 19 | | |
0 commit comments