Skip to content

New format for trait redefined final method from AnyRef error message… #3447

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

Conversation

thebignet
Copy link
Contributor

Further enhancement : explanation could be enhanced by telling which method from AnyRef was redefined

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only have on error message for overridden final value/def. We should not special case for traits that override a method in AnyRef

@thebignet
Copy link
Contributor Author

I understand what you mean. I had the same thought as to why should there be such a specific check. I think it is explained by this comment.

Have to use matchingSymbol, not a method involving overridden symbols, because the scala type system understands that an abstract method here does not override a concrete method in Object. The jvm, however, does not.

According to notes on RefsChecks.scala:127, 1.2 says that final members of classes should not be overriden. Maybe it is because AnyRef is a trait (and not a class), so implementing a final def should normally work, but since methods like wait are implemented in the JVM for all Objects, there is a special case.

This is my first PR on dotty and I have no claim to be an expert. Is this explanation correct ?

@allanrenucci allanrenucci self-assigned this Nov 16, 2017
@allanrenucci allanrenucci force-pushed the trait-redefined-final-method-from-any-ref branch from f038212 to b092560 Compare November 18, 2017 19:14
@allanrenucci allanrenucci merged commit b4e8acd into scala:master Nov 18, 2017
@maseev maseev mentioned this pull request Nov 22, 2017
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.

3 participants