immutables / immutables-vavr

Immutables encodings for Vavr
Other
33 stars 7 forks source link

Make Option's "with" method behaviour consistent with builder logic #26

Closed Rafal-Spryszynski closed 4 years ago

Rafal-Spryszynski commented 4 years ago

Option's logic when creating object and when using "with" generated method are inconsistent.

Consider this test class:

@VavrOptionEncodingEnabled
@Value.Immutable
interface TestObject {

  Option<Integer> option();
}

This test yields:

ImmutableTestObject testObject = ImmutableTestObject.builder()
  .option((Integer) null)
  .build();

Assert.assertEquals(testObject, testObject.withOption((Integer) null));

expected:<TestObject{option=None}> but was:<TestObject{option=Some(null)}>

I've created pull request to fix it:

25

Rafal-Spryszynski commented 4 years ago

I have to rethink where is the real problem.