Skip to content
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

How about something like Final by Default #6

Closed
bangarharshit opened this issue Apr 1, 2019 · 4 comments
Closed

How about something like Final by Default #6

bangarharshit opened this issue Apr 1, 2019 · 4 comments

Comments

@bangarharshit
Copy link

Probably a check which checks if the class is not marked with @Open or abstract should not have any subclasses.

On a related note, it will be a great thing to have FinalByDefault (similar to NonNullByDefault) baked in the type system via EP check or checker framework.

@JakeWharton
Copy link
Owner

If it's not @Open or abstract though then what is it? Isn't final all that's left?

@bangarharshit
Copy link
Author

bangarharshit commented Apr 1, 2019

Fair point. Just avoiding the keyword final. It should be declared @Open or abstract. In the current check Non-final, Non-abstract classes without the @Open annotation will be marked with an error.. How about just treating them as final. All things are final by default and you have to mark @Open to make it subclassable.

@JakeWharton
Copy link
Owner

That still allows their subclassing by downstream libraries. I suppose if the type isn't effectively public then perhaps the check shouldn't apply?

@bangarharshit
Copy link
Author

Oh. Didn't think of this use case.

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

No branches or pull requests

2 participants