Skip to content

Java: Make JumpStmt a proper superclass #8582

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 3 commits into from
Apr 25, 2022

Conversation

Marcono1234
Copy link
Contributor

Resolves #8569

@@ -0,0 +1,4 @@
---
category: fix
Copy link
Contributor Author

@Marcono1234 Marcono1234 Mar 28, 2022

Choose a reason for hiding this comment

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

Not really a "fix", but the other categories do not seem to fit much better either. Maybe it should be "feature"?

@Marcono1234 Marcono1234 force-pushed the marcono1234/JumpStmt-superclass branch from ec5d537 to a93b4ed Compare March 29, 2022 22:30
@Marcono1234
Copy link
Contributor Author

Thanks for the feedback; have addressed it and force pushed the changes.

Copy link
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

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

Generally looks good to me, but we should avoid making JumpStmt an abstract class.

@@ -557,13 +557,7 @@ class ThrowStmt extends Stmt, @throwstmt {
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We generally try to avoid exposing public abstract classes like this, since subclassing using extends can lead to surprising results. It is better to define the union type explicitly:

Suggested change
private class JumpStmt_ = @breakstmt or @yieldstmt or @continuestmt;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, thanks! I have implemented your suggestion manually, and added a small comment explaining the rationale; hopefully that is alright.

A bit unrelated, but I have created a #8713 to discuss making implementing abstract classes less error-prone.

Public abstract classes can be error-prone, when users unintentionally
implement a new subclass instead of refining the set of existing subclasses.
@aschackmull aschackmull merged commit cbdd492 into github:main Apr 25, 2022
@Marcono1234 Marcono1234 deleted the marcono1234/JumpStmt-superclass branch April 25, 2022 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Java: Make JumpStmt a proper superclass
3 participants