diff --git a/value-fixture/test/org/immutables/fixture/modifiable/ModifiablesTest.java b/value-fixture/test/org/immutables/fixture/modifiable/ModifiablesTest.java index b9ea56624..4705507f6 100644 --- a/value-fixture/test/org/immutables/fixture/modifiable/ModifiablesTest.java +++ b/value-fixture/test/org/immutables/fixture/modifiable/ModifiablesTest.java @@ -1,6 +1,8 @@ package org.immutables.fixture.modifiable; +import static org.hamcrest.core.IsEqual.equalTo; import static org.immutables.check.Checkers.*; + import org.junit.Test; public class ModifiablesTest { @@ -81,6 +83,11 @@ public void uninitializedEquals() { check(c1).not().is(c2); } + @Test + public void equalsWithDifferenObjectType() { + check(ModifiableCompanion.create()).not().is(equalTo(new Object())); + } + @Test public void defaults() { ModifiableStandalone m = ModifiableStandalone.create(); diff --git a/value-processor/src/org/immutables/value/processor/Modifiables.generator b/value-processor/src/org/immutables/value/processor/Modifiables.generator index 71dbf4c3e..355bbbf75 100644 --- a/value-processor/src/org/immutables/value/processor/Modifiables.generator +++ b/value-processor/src/org/immutables/value/processor/Modifiables.generator @@ -662,7 +662,7 @@ if ([v.name]Value != null) { @Override public boolean equals([atNullable]Object another) { if (this == another) return true; - if (!(this instanceof [equalToType])) return false; + if (!(another instanceof [equalToType])) return false; [equalToType] o = ([equalToType]) another; [if type.mandatoryAttributes] if (![isInitialized type]() || !o.[isInitialized type]()) {