Expected behavior
When a target class is annotated @NullMarked, unannotated constructor parameters should be treated as @NonNull. Mapping a @Nullable source to such a parameter without a default value should produce a compile error.
Given:
@NullMarked
public class Target {
private final Nested nested;
public Target(Nested nested) { this.nested = nested; } // implicitly @NonNull
}
@NullMarked
public class Source {
private final @Nullable Nested nested;
public @Nullable Nested getNested() { return nested; }
}
@Mapper
@NullMarked
public interface Issue4079Mapper {
Target map(Source source);
}
Expected: compilation fails with
error: Can't map potentially nullable source property "nested" to @NonNull constructor parameter "nested".
Actual behavior
Compilation succeeds.
Steps to reproduce the problem
Can be reproduced in this branch: main...RaniAgus:mapstruct:issues/4079
MapStruct Version
1.7.0.Beta2
Expected behavior
When a target class is annotated
@NullMarked, unannotated constructor parameters should be treated as@NonNull. Mapping a@Nullablesource to such a parameter without a default value should produce a compile error.Given:
Expected: compilation fails with
Actual behavior
Compilation succeeds.
Steps to reproduce the problem
Can be reproduced in this branch: main...RaniAgus:mapstruct:issues/4079
MapStruct Version
1.7.0.Beta2