Sum types are not diffed correctly
exFalso opened this issue · 0 comments
exFalso commented
Given a class SomeClass that has a field of an interface type(or superclass) A and given two instances of SomeClass, one having B extends A in that field, another having C extends A then these aren't diffed correctly (it returns UNTOUCHED) because the property diffing is based on the field's type rather than the actual instances' types.
example:
import de.danielbechler.diff.ObjectDifferBuilder;
class Asd {
public interface A {
}
public static final class B implements A {
private final int asd = 0;
public final int getAsd() {
return this.asd;
}
}
public static final class C implements A {
private final String fgh = "";
public final String getFgh() {
return this.fgh;
}
}
public static final class SomeClass {
private final A a;
public final A getA() {
return this.a;
}
SomeClass(A a) {
this.a = a;
}
}
public static void main(String[] args) {
System.out.println(ObjectDifferBuilder.buildDefault().compare(new SomeClass(new B()), new SomeClass(new C())));
}
}