Update assertion to account for computing NOT_COMPUTED_HASH_CODE
Bug: 153391780
Change-Id: Id2e55bf02efe47969c11171fa1384a3d32a7a19b
diff --git a/src/main/java/com/android/tools/r8/graph/CachedHashValueDexItem.java b/src/main/java/com/android/tools/r8/graph/CachedHashValueDexItem.java
index 749ce04..eda8647 100644
--- a/src/main/java/com/android/tools/r8/graph/CachedHashValueDexItem.java
+++ b/src/main/java/com/android/tools/r8/graph/CachedHashValueDexItem.java
@@ -26,11 +26,20 @@
}
hash = cache;
}
- assert cache == computeHashCode()
- : "Hash code for " + this + " has changed from " + hash + " to " + computeHashCode();
+ assert verifyHashCodeConsistent(cache);
return cache;
}
+ private boolean verifyHashCodeConsistent(int computedValue) {
+ int newComputedValue = computeHashCode();
+ if (newComputedValue == NOT_COMPUTED_HASH_VALUE) {
+ newComputedValue = SENTINEL_HASH_VALUE;
+ }
+ assert computedValue == newComputedValue
+ : "Hash code for " + this + " has changed from " + hash + " to " + newComputedValue;
+ return true;
+ }
+
@Override
public void flushCachedValues() {
super.flushCachedValues();