Honor JSpecify nullability of reused mapping methods - #4110
Conversation
|
Issue #4086 is only partially fixed by PR #4110. The reused method's result nullability is honoured when it is provable - either an explicit @kush2439p plz verify using the verbatim snippet from #4086 |
Add handling for nullable source parameters in assignment.
|
Verified and fixed using the verbatim #4086 shape. The new payload = mapValue( source.getValue() );
Target target = new Target( payload );The compatibility rule is intentionally narrow: a helper that accepts Verification:
The PR is ready for review. |
Summary
Fixes #4106 by carrying the JSpecify input and output contracts of reused mapping methods through generated assignments.
MapStruct previously based null guards primarily on source/target nullability and null-value-check strategy. It did not retain whether a selected helper method required a non-null argument or guaranteed a non-null result, which could generate unsafe calls or reject safe constructor mappings.
Implementation
usestypes.@Nullable, preserving legacy behavior for unannotated return types.-Amapstruct.disableJSpecify=true.This also covers the related scenarios described in #4077, #4081, and #4086 without adding public API.
Verification
mapValue(source.getValue())directly.@Nullablereturn negative case: still produces the expected non-null-constructor diagnostic.JSpecify*Testsuite: 111 tests passed.MavenIntegrationTest#fullFeatureTest: passed.The full reactor
clean install -DskipDistribution=trueexceeded the local 15-minute command limit after the processor suite completed; the affected integration path and Checkstyle were rerun successfully afterward.