Use case
With JSpecify, the generated code is not compliant with the contract of the method.
So the generated code can't be part of NullAway check.
This is the Mapper declaration we have with @NullMarked so both parameter and return value are not null:
null)")
public abstract CommonInstrumentEmbeddedDto toEmbeddedDto(Instrument entity);
The target Dto, one nullable and one not nullable:
public record CommonInstrumentEmbeddedDto(
String name,
@Nullable String shortName
) {}
Generated source:
@Override
public CommonInstrumentEmbeddedDto toEmbeddedDto(IInstrument entity) {
if ( entity == null ) {
return null;
}
String name = null;
String shortName = null;
name = entity.getName();
shortName = entity.getShortName();
CommonInstrumentEmbeddedDto commonInstrumentEmbeddedDto = new CommonInstrumentEmbeddedDto( name, shortName);
return commonInstrumentEmbeddedDto;
}
Generated Code
NonNull returned:
When the return value is known to be not null, we should not have this part:
if ( entity == null ) {
return null;
}
And map struct should probably fails during the mapping if the parameter could be null.
Possible workarounds
No response
MapStruct Version
1.7.0.Beta2
Use case
With JSpecify, the generated code is not compliant with the contract of the method.
So the generated code can't be part of NullAway check.
This is the Mapper declaration we have with
@NullMarkedso both parameter and return value are not null:The target Dto, one nullable and one not nullable:
Generated source:
Generated Code
NonNull returned:
When the return value is known to be not null, we should not have this part:
And map struct should probably fails during the mapping if the parameter could be null.
Possible workarounds
No response
MapStruct Version
1.7.0.Beta2