Replace CtClass.constructors model from Set to List #646
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
// 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.