Fix less-than for annotations with specific types
Change-Id: Ie868b684bdfed0a14c177696a7ff17dae0fe894b
diff --git a/src/main/java/com/android/tools/r8/shaking/KeepAnnotationCollectionInfo.java b/src/main/java/com/android/tools/r8/shaking/KeepAnnotationCollectionInfo.java
index cd7bf16..d1e1d5b 100644
--- a/src/main/java/com/android/tools/r8/shaking/KeepAnnotationCollectionInfo.java
+++ b/src/main/java/com/android/tools/r8/shaking/KeepAnnotationCollectionInfo.java
@@ -294,14 +294,17 @@
// Our specific types are "bottom" so this is less than.
return true;
}
- if (other.specificTypeInfo == null) {
- // Other specific types are "bottom" and this is not bottom, so it is not less than.
- return false;
- }
- // Check that each specific type is less than the content of the type in other.
+ // Check that each specific type is less than the content of the type in other or its
+ // any-type when not present.
for (DexType type : specificTypeInfo.keySet()) {
- KeepAnnotationInfo otherInfo = other.specificTypeInfo.get(type);
- if (otherInfo == null || !specificTypeInfo.get(type).isLessThanOrEqualTo(otherInfo)) {
+ KeepAnnotationInfo otherInfo = null;
+ if (other.specificTypeInfo != null) {
+ otherInfo = other.specificTypeInfo.get(type);
+ }
+ if (otherInfo == null) {
+ otherInfo = other.anyTypeInfo;
+ }
+ if (!specificTypeInfo.get(type).isLessThanOrEqualTo(otherInfo)) {
return false;
}
}