fix: resolve duplicate invocation of overloaded lifecycle methods with inheritance#3856
fix: resolve duplicate invocation of overloaded lifecycle methods with inheritance#3856filiphr merged 3 commits intomapstruct:mainfrom
Conversation
15f7b6d to
583f3cf
Compare
filiphr
left a comment
There was a problem hiding this comment.
Thanks @tangyang9464, the solution looks good to me. I've left some comments, which are mainly for performance optimization, as this can get called a lot, especially if you have a lot of lifecycle methods.
Additionally, I think that it'll be good if we can add some tests with generics. I am not sure whether everything would fine then.
Also, can we perhaps add some compiler flag so that people can disable this particular selector in case it causes them performance problems and / or something isn't working properly, just in case. I think we can pass the Options to the MethodsSelectors and then check whether we should include this new one or not. What do you think about that?
...va/org/mapstruct/ap/internal/model/source/selector/LifecycleOverloadDeduplicateSelector.java
Outdated
Show resolved
Hide resolved
...va/org/mapstruct/ap/internal/model/source/selector/LifecycleOverloadDeduplicateSelector.java
Outdated
Show resolved
Hide resolved
...va/org/mapstruct/ap/internal/model/source/selector/LifecycleOverloadDeduplicateSelector.java
Outdated
Show resolved
Hide resolved
...va/org/mapstruct/ap/internal/model/source/selector/LifecycleOverloadDeduplicateSelector.java
Outdated
Show resolved
Hide resolved
|
btw, the build is failing due to the javadoc |
|
I'll modify based on the comments and fix CICD later |
2. add test for compile args and generic Signed-off-by: TangYang <[email protected]>
5c5e342 to
d511439
Compare
Signed-off-by: TangYang <[email protected]>
d511439 to
3de0b37
Compare
|
@filiphr plz review again. I did the following:
|
|
@filiphr any viewpoint? |
|
Thanks for the changes @tangyang9464. During the week it's a bit more difficult for me to check these stuff out. I'll review it soon and merge it |
fix: 3849
Newly added
LifecycleOverloadDeduplicateSelector, which uses multiple features such as class name and method name as keys to group methods.And then selects the best method within the group by comparing the inheritance distance of parameters,
to achieve deduplication between similar overloaded methods.
The parameters involved in the inheritance distance calculation are not limited to
@MappingTarget, but all input parameters of a group of candidate methods are traversed and calculated in sequence until a parameter is found with the shortest distance, then the traversal is terminated. (Avoid the situation where the @MappingTarget parameter type is the same but other parameters are different).