Expected behavior
Correct code is generated
Actual behavior
code that cannot be compiled is generated
Steps to reproduce the problem
I've created a repo to reproduce the problem https://github.com/chpasha/mapstruct_bug/tree/master/src/main/java/com/example/demo
for the update method of the mapper
public abstract class SwTerminMapper {
@Mapping(target = "datum", source = "termin.termin")
public abstract void updateFromRequest(UpdateSwTerminRequest request, @MappingTarget SwTermin termin);
}
following broken code is generated
@Override
public void updateFromRequest(UpdateSwTerminRequest request, SwTermin termin) {
if ( termin.getDatum() == null ) {
termin.setDatum( new LocalDate() );
}
localDateTimeToLocalDate1( termin1, termin.getDatum() );
}
here termin1 variable is undefined. if I remove jspecify (delete package-info.java)
correct code is generated like this
@Override
public void updateFromRequest(UpdateSwTerminRequest request, SwTermin termin) {
if ( request == null ) {
return;
}
LocalDateTime termin1 = requestTerminTermin( request );
if ( termin1 != null ) {
if ( termin.getDatum() == null ) {
termin.setDatum( new LocalDate() );
}
localDateTimeToLocalDate1( termin1, termin.getDatum() );
}
else {
termin.setDatum( null );
}
}
It is important to notice, that LocalDate, LocalTime and LocalDateTime classes in my examples are custom, not from JDK (don't ask) - but they are crucial for replication of the bug, since they need conversion methods (which are correctly generated by mapstruct without intervention from my side)
MapStruct Version
MapStruct 1.7.0.Beta2
Expected behavior
Correct code is generated
Actual behavior
code that cannot be compiled is generated
Steps to reproduce the problem
I've created a repo to reproduce the problem https://github.com/chpasha/mapstruct_bug/tree/master/src/main/java/com/example/demo
for the update method of the mapper
following broken code is generated
here termin1 variable is undefined. if I remove jspecify (delete package-info.java)
correct code is generated like this
It is important to notice, that LocalDate, LocalTime and LocalDateTime classes in my examples are custom, not from JDK (don't ask) - but they are crucial for replication of the bug, since they need conversion methods (which are correctly generated by mapstruct without intervention from my side)
MapStruct Version
MapStruct 1.7.0.Beta2