-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #4936: Forbid (or warn on) redundant/illegal object flags #4973
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
Fix #4936: Forbid (or warn on) redundant/illegal object flags #4973
Conversation
could be done in the parser no? |
1ecf67b
to
91b540c
Compare
@Blaisorblade Inactive for almost 5 months. Can you either finish the PR or close it and re-assign the issue to someone else? Thanks |
6dcd45e
to
debfde5
Compare
@@ -1 +0,0 @@ | |||
sealed object Fun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This testcase was added in #3486 for #3471 to ensure the compiler didn't crash.
During the discussion, it was demanded that final
be handled at the same time, which is done here: #3486 (comment).
debfde5
to
0e6095b
Compare
That comment does apply, and I guess it overrides contrary suggestions above. |
On hold, waiting for decision on flags in #5525. |
19ce196
to
2b6ec51
Compare
FWIW, the current CI failure is spurious; while this is on hold, I'd like to get it working as far as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test in tests/neg-custom-args/fatal-warnings
with
final object Foo // error
Otherwise LGTM
799c6c2
to
d547ea4
Compare
Fix scala#4936 in parser. - Stop using final object in our sources. - Give error for abstract and sealed objects, warning for final ones (as long as - scala/bug#11094 is open). - Address review comments.
d547ea4
to
a17b0b6
Compare
@nicolasstucki I've done that change, so it could be merged, but @odersky in #5525 suggested centralizing flag checking. Assigning to you for decision. |
We can centralize them later in #5525. |
I am afraid this is the wrong fix. See our long discussion with Allan. Flag combinations should not be tested in Parser, we discussed this and decided on it. Please let's revert these commits and do it from the ground up at the same time as #5525. |
Scalac sometimes *forgets* the final bytecode flag, and sometimes one cares, so people even *recommend* always writing *final object* instead of object. That's bad, since we started warning about it in scala#4973. scala/bug#11094 (comment) https://nrinaudo.github.io/scala-best-practices/adts/final_case_objects.html Why care? ========= If we forget the final flag in bytecode, Java code might then extend the class. Performance might or might not be affected - some in scala/contributors debated this for ~20 minutes (starting at https://gitter.im/scala/contributors?at=5c423c449bfa375aab21f2af).
Scalac sometimes *forgets* the final bytecode flag, and sometimes one cares, so people even *recommend* always writing *final object* instead of object. That's bad, since we started warning about it in scala#4973. scala/bug#11094 (comment) https://nrinaudo.github.io/scala-best-practices/adts/final_case_objects.html Why care? ========= If we forget the final flag in bytecode, Java code might then extend the class. Performance might or might not be affected - some in scala/contributors debated this for ~20 minutes (starting at https://gitter.im/scala/contributors?at=5c423c449bfa375aab21f2af).
Scalac sometimes *forgets* the final bytecode flag, and sometimes one cares, so people even *recommend* always writing *final object* instead of object. That's bad, since we started warning about it in scala#4973. scala/bug#11094 (comment) https://nrinaudo.github.io/scala-best-practices/adts/final_case_objects.html Why care? ========= If we forget the final flag in bytecode, Java code might then extend the class. Performance might or might not be affected - some in scala/contributors debated this for ~20 minutes (starting at https://gitter.im/scala/contributors?at=5c423c449bfa375aab21f2af).
Forbid/warn on redundant/illegal object flags — fix #4936.
Forbid
final object
bug#11094 is open).