You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
Default values set on a nested buildable type in the constructor should be ignored when merging, but unfortunately they are currently treated as explicitly-set values, as the merge method in the nested mergeFrom method uses the defaults from its own constructor.
e.g.
@FreeBuilderinterfaceTypeA {
intvalue(); // No defaultclassBuilderextendsTypeA_Builder { }
}
@FreeBuilderinterfaceTypeB {
TypeAa(); // Value defaults to 0 on this typeclassBuilderextendsTypeB_Builder {
Builder() {
super().mutateA(a -> a.value(0));
}
}
}
TypeB.Builderx = newTypeB.Builder();
TypeB.Builderb = newTypeB.Builder();
b.a().value(10);
b.mergeFrom(x); // This should not overwrite a.valuey = b.build();
assertEquals(10, y.a()); // Fails
Not sure how to easily fix this — would probably require an API extension, to have the option of passing a different default into the mergeFrom algorithm. It would also break existing code, so probably needs to be a major version bump when fixed.
The text was updated successfully, but these errors were encountered:
Default values set on a nested buildable type in the constructor should be ignored when merging, but unfortunately they are currently treated as explicitly-set values, as the merge method in the nested
mergeFrom
method uses the defaults from its own constructor.e.g.
Not sure how to easily fix this — would probably require an API extension, to have the option of passing a different default into the mergeFrom algorithm. It would also break existing code, so probably needs to be a major version bump when fixed.
The text was updated successfully, but these errors were encountered: