Skip to content

Conversation

@EvaristeGalois11
Copy link
Contributor

Fix #3202

I had to remove one of the @SubclassMapping annotations from the erroneous mappers because otherwise the tests would fail.

It seems that if more than one annotations of the same type as AnnotationMirror are present on the mapping method the compiler will fallback to emit the error on the method itself. Eclipse compiler seems to work fine regardless of the number of annotations. Is this an already known issue?

Copy link
Member

@filiphr filiphr left a comment

Choose a reason for hiding this comment

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

Thanks @EvaristeGalois11. The PR looks great, only one small cosmetic comment regarding the prefix Gem in fields and variables. We are usually not using it in other places, e.g. MappingOptions, BeanMappingOptions.

It seems that if more than one annotations of the same type as AnnotationMirror are present on the mapping method the compiler will fallback to emit the error on the method itself. Eclipse compiler seems to work fine regardless of the number of annotations. Is this an already known issue?

This is indeed a known issue. I think that newer Java compiler versions have fixed this. The eclipse compiler always worked fine. You don't need to remove anything from the code you can use the alternativeLine in the @Diagnostic. You can actually remove in one place and leave in the other, to make sure that we really do report in the right place in both cases. As an example with this similar problem is AnnotateWithTest#mapperWithIdenticalAnnotationRepeated

@EvaristeGalois11
Copy link
Contributor Author

Thank you @filiphr for your feedback! I have updated the PR with what you said.

I had to change the copyForInverseInheritance method a bit because i couldn't find a combination of variables name that wasn't awkard, I hope it isn't a problem.

@filiphr filiphr merged commit b1034e6 into mapstruct:main Apr 22, 2023
@filiphr
Copy link
Member

filiphr commented Apr 22, 2023

Thanks @EvaristeGalois11

@EvaristeGalois11 EvaristeGalois11 deleted the issue/3202 branch April 22, 2023 16:28
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.

Improve line location report for invalid qualifier for SubclassMapping

2 participants