mapstruct / mapstruct-idea

An IntelliJ IDEA plugin for working with MapStruct
Other
141 stars 38 forks source link

Incorrect unmapped target warning for fluent setters #121

Closed andye2004 closed 1 year ago

andye2004 commented 1 year ago

I know there have been a few of these reported, but this appears to be slightly different to the others I've read over.

At the organisation I work for we use avro schema files to generate classes and any time we use these generated files as the mapping target of a mapper we get an Add unmapped target property: 'get' warning from the IntelliJ IDEA plugin.

The issue is not specifically related to the code generated by avro, but instead is related to over-ridden methods of an abstract base class that should return a java.lang.Object. This happens as MapstructUtil.isFluentSetter() determines that the method is part of a builders fluent setter pattern, even when builders are explicitly disabled.

I have put together an example of the issue here, although the example project doesn't use avro it does highlight the issue as outlined.

filiphr commented 1 year ago

I do agree that this is a a bug, but the reason is not because the builders are enabled. If you see how the MapStruct processor works you'll see that irregardless whether builders are enabled or disabled there will be no warning for unmapped property.

This needs to be fixed by making sure that the fluent setter return type is assignable to the type being mapped