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

Allow SimpleLiteral to be a vararg #143

Merged
merged 3 commits into from
Jan 1, 2024
Merged

Conversation

TheLimeGlass
Copy link
Contributor

Allow SimpleLiteral to be a vararg for accepting a single value.

Allow SimpleLiteral to be a vararg

public SimpleLiteral(T[] values) {
public SimpleLiteral(T... values) {
Copy link
Owner

Choose a reason for hiding this comment

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

Won't this create issues for SyntaxParser at line 538? Those lines over there should be changed as well. Also, should the other constructor be removed as well or can it make a difference? I'm not experienced enough with Java generics to know if that constructor should exist or not (because it already has a varargs parameter).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't, but it'll remove that whole Array newInstance. Epic. I will get around to changing that soon.

Mwexim added 2 commits January 1, 2024 12:50
…pleLiteral

Vararg generics are just not the way to go in Java and the code was not working when you'd use it as expected. The original changes were therefore reverted, but there was still a small change left in the SimpleLiteral class.
@Mwexim
Copy link
Owner

Mwexim commented Jan 1, 2024

Sorry to hijack this pull request like this. My original intention was to just add the changes I proposed, but then I saw that the proposal itself is just not a good idea because of the way varargs and generics are handled (there's a reason the original author Syst3ms) added a specific constructor that needed a class argument as well).

That said, I still made some minor changes, hence why I'm still merging the pull request.

@Mwexim Mwexim merged commit 2c83253 into Mwexim:master Jan 1, 2024
@TheLimeGlass TheLimeGlass deleted the patch-2 branch March 8, 2024 06:18
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