Skip to content

Improve invariant checks for erased terms #12095

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 1 commit into from
Apr 27, 2021

Conversation

nicolasstucki
Copy link
Contributor

Instead of erasing an erased term to ??? we erase it to erasedValue[T].
This has 2 advantages, first, the term does not lose its type, and second, the
term is still marked as erased. The second implies that if there is a bug in
the compiler or a macro where the term might end outside an erased context, the
code will not compiler. Currently, the code compiles and then throws when
calling the spurious ???. See #11996.

@nicolasstucki nicolasstucki force-pushed the improve-erased-terms-erasure branch from 4c59649 to 865c662 Compare April 15, 2021 09:03
@nicolasstucki
Copy link
Contributor Author

Seems that it caught a bug in tests/pos/i11864.scala

@nicolasstucki
Copy link
Contributor Author

That failure was just another instance of #11996

@nicolasstucki nicolasstucki force-pushed the improve-erased-terms-erasure branch from 865c662 to d3f08a7 Compare April 15, 2021 09:27
@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Apr 15, 2021

Based on #12027

@nicolasstucki nicolasstucki self-assigned this Apr 15, 2021
@nicolasstucki nicolasstucki force-pushed the improve-erased-terms-erasure branch 3 times, most recently from d7922bd to 5cad755 Compare April 20, 2021 10:26
Instead of erasing an erased term to `???` we erase it to `erasedValue[T]`.
This has 2 advantages, first, the term does not lose its type, and second, the
term is still marked as erased. The second implies that if there is a bug in
the compiler or a macro where the term might end outside an erased context, the
code will not compiler. Currently, the code compiles and then throws when
calling the spurious `???`. See scala#11996.
@nicolasstucki nicolasstucki force-pushed the improve-erased-terms-erasure branch from 5cad755 to e152abe Compare April 22, 2021 13:11
@nicolasstucki nicolasstucki marked this pull request as ready for review April 22, 2021 15:17
@nicolasstucki nicolasstucki requested a review from odersky April 22, 2021 15:18
@odersky odersky merged commit 3984c67 into scala:master Apr 27, 2021
@odersky odersky deleted the improve-erased-terms-erasure branch April 27, 2021 08:01
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