Commit 7bcae33
Harden erasure of TermRefs
If a getter TermRef has a MethodType, erase it to the erasure of the method
result type.
Fixes #15649
Since the fault in #15649 is highly non-deterministic, I can only guess what the reason
was. I think what happened was that the TermRef was created very late, when the TermRef
was already a getter. I.e. after phase `Getters`, which is itself after `Erasure`. The
whole thing was launched from the code that generates static forwarders in the backend.
Type erasure is run at erasure phase, but if there is no previous denotation of the `TermRef`,
it will keep the first one it read, which would have the `MethodType` as underlying type.
The end result was that the `TermRef` was erased to a method type, where it should have
been erased to the result type. Consequently, we ended up with a MethodType as the
parameter type of another method, which is unexpected.
But all that is just a guess. I am not even sure this PR will fix the problem since it
comes up so rarely.1 parent 9fa1f48 commit 7bcae33
File tree
2 files changed
+19
-2
lines changed- compiler/src/dotty/tools/dotc/core
- tests/pos
2 files changed
+19
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
602 | | - | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
603 | 605 | | |
604 | 606 | | |
605 | 607 | | |
| |||
684 | 686 | | |
685 | 687 | | |
686 | 688 | | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
687 | 693 | | |
688 | 694 | | |
689 | 695 | | |
| |||
829 | 835 | | |
830 | 836 | | |
831 | 837 | | |
832 | | - | |
| 838 | + | |
833 | 839 | | |
834 | 840 | | |
835 | 841 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments