Skip to content

Backport #15658: Harden erasure of TermRefs #15751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 27, 2022

Conversation

Kordyjan
Copy link
Contributor

Backports #15658

@Kordyjan Kordyjan added this to the 3.2.0 backports milestone Jul 26, 2022
@Kordyjan Kordyjan changed the title Backport #15658 Backport #15658: Harden erasure of TermRefs Jul 26, 2022
odersky added 2 commits July 26, 2022 14:57
If a getter TermRef has a MethodType, erase it to the erasure of the method
result type.

Fixes scala#15649

Since the fault in scala#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.
@Kordyjan Kordyjan mentioned this pull request Jul 26, 2022
23 tasks
@Kordyjan Kordyjan merged commit 35dd912 into scala:release-3.2.0 Jul 27, 2022
@Kordyjan Kordyjan deleted the backport-15658 branch July 27, 2022 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants