!27802 Fix a bug in AbstractBase::operator==()

Merge pull request !27802 from hewei/fix_abs_equal
This commit is contained in:
i-robot 2021-12-17 01:54:43 +00:00 committed by Gitee
commit 4daacb6f7f
1 changed files with 15 additions and 4 deletions

View File

@ -94,10 +94,21 @@ bool AbstractBase::operator==(const AbstractBase &other) const {
// Same object.
return true;
}
return tid() == other.tid() && // c++ type equal and
IsEqual(type_, other.type_) && // type equal and
IsEqual(shape_, other.shape_) && // shape equal and
IsEqual(value_, other.value_); // value equal.
// Check C++ type.
if (tid() != other.tid()) {
return false;
}
// Check data type.
if (!IsEqual(type_, other.type_)) {
return false;
}
// If both are "undetermined" type, they are considered equal.
if (type_ == kAnyType && BuildType()->type_id() == kObjectTypeUndeterminedType &&
other.BuildType()->type_id() == kObjectTypeUndeterminedType) {
return true;
}
// Check shape and value.
return IsEqual(shape_, other.shape_) && IsEqual(value_, other.value_);
}
ValuePtr AbstractBase::BuildValue() const {