Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/EqualsTwoFields.java
Tagir Valeev 289681a13d [java-dfa] Take into account types when comparing ContractTempDescriptors
Even if we flush temp variables after every method call, they are kept in DfaValueFactory, so if we create an equal descriptor later, the old variable will be reused, even if it had a different type. This caused wrong contract evaluation for the second call.
Fixes IDEA-280534 Constant conditions & exceptions. False positive "Result of 'getComment().equals(tag.getComment())' is always 'false'"

GitOrigin-RevId: 918eca6110e5b416b78430b1e3f30d40fe28d9a7
2021-10-19 10:09:36 +00:00

34 lines
610 B
Java

import org.jetbrains.annotations.NotNull;
// IDEA-280534
class TagImpl {
boolean test(TagImpl o) {
if (!getKey().equals(o.getKey())) return false;
return getComment().equals(o.getComment());
}
private final TagKey tagKey;
private final String comment;
public TagImpl(Number owner, String comment) {
this.tagKey = new TagKey(owner);
this.comment = comment;
}
@NotNull
public TagKey getKey() {
return tagKey;
}
public String getComment() {
return comment;
}
}
class TagKey {
private final Number owner;
TagKey(Number owner) {
this.owner = owner;
}
}