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

List<subclass> is currently not allowed in addAll method #1199

Closed
dmm9 opened this issue Dec 15, 2023 · 2 comments
Closed

List<subclass> is currently not allowed in addAll method #1199

dmm9 opened this issue Dec 15, 2023 · 2 comments
Labels
bug Something isn't working server-java
Projects

Comments

@dmm9
Copy link

dmm9 commented Dec 15, 2023

The GModelElementBuilder.addAll() method should accept lists of different types, as long as it extends GModelElement.

i.e. Currently, this fails to compile:

List<GNode> nodeList = new ArrayList<>();
nodeList.add(...);

parent.addAll(nodeList); // error

A good explanation why the Java compiler rejects List<subclass> as argument can be found in this stackoveflow question.

It fixes by changing function signature from:

public E addAll(final List<GModelElement> children)

to

public E addAll(final List<? extends GModelElement> children)
@dmm9 dmm9 added the bug Something isn't working label Dec 15, 2023
@planger planger added this to New in GLSP kanban via automation Dec 15, 2023
@planger
Copy link
Member

planger commented Dec 15, 2023

Thanks for reporting this issue! This indeed seems like an oversight. Would you be able to open a PR to fix it @dmm9? Thank you!

@dmm9
Copy link
Author

dmm9 commented Dec 15, 2023

yes I am already working on it :)

dmm9 added a commit to dmm9/glsp-server that referenced this issue Dec 15, 2023
GLSP kanban automation moved this from New to Done Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server-java
Projects
No open projects
GLSP kanban
  
Done
Development

No branches or pull requests

2 participants