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

Replace CtClass.constructors model from Set to List #646

Closed
wants to merge 1 commit into from

Conversation

leventov
Copy link
Contributor

@leventov leventov commented May 4, 2016

// TODO: CHANGE SETS TO LIST TO AVOID HAVING TO DO THIS says for itself, and I also encountered this issue in my use cases.

Generally, it seems hardly ever sensible to have any AST children node collections as Sets. Because finally it's AST user responsibility to generate correct code. I think, framework shouldn't be "too smart" trying to do something for us in terms of Java source code semantics, i. e. making constructors/methods unique. It will be a java compiler error, finally, if we have two identical methods/constructors in a class body. On the other hand, pattern clone method -> insert into method list -> update list of arguments, body.. is pretty reasonable, but it is ruled out by the current Set (and constructors, regaring this PR).

Though all collections should be Lists (IMO), even for lists we should probably check that some element (java object) is not inserted twice into any list. Because it is definitely a programmic error (like addressed by #645 ) and could lead to hard to find bugs, if replace/clone/traverse takes place.

@monperrus
Copy link
Collaborator

I'm not against such change, although we would make it carefully, since it breaks client code.

Below a generic discussion on what frameworks should do, what is the concrete problem with having a Set in constructors?

@monperrus
Copy link
Collaborator

Closing this one. In Spoon, we take a great care of balancing improvement and backward compatibility. Don't hesitate to reopen it if necessary.

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