Always generate conversion to most specific wrapper
Change-Id: I2a9f633bbb409a4f2a4f63d08234c4af7b71ed89
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineWrapperConverter.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineWrapperConverter.java
index e471367..5fef044 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineWrapperConverter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineWrapperConverter.java
@@ -49,7 +49,6 @@
// processed before.
LinkedHashMap<DexType, WrapperDescriptorBuilder> orderedDescriptors =
orderDescriptors(descriptors);
- clearIncompleteSubwrappers(orderedDescriptors, rewritingFlags.getWrapperConversions());
finalizeWrapperDescriptors(orderedDescriptors, builder);
warnConsumer.accept("The following types to wrap are missing: ", missingClasses);
warnConsumer.accept(
@@ -57,22 +56,6 @@
invalidMethods);
}
- private void clearIncompleteSubwrappers(
- LinkedHashMap<DexType, WrapperDescriptorBuilder> orderedDescriptors,
- Map<DexType, Set<DexMethod>> wrapperConversions) {
- // If the wrapper is incomplete, it may lead to runtime errors.
- // We never try to specialize the wrapper to an incomplete wrapper for this reason.
- for (WrapperDescriptorBuilder descriptor : orderedDescriptors.values()) {
- List<DexType> toRemove = new ArrayList<>();
- for (DexType subwrapper : descriptor.getSubwrappers()) {
- if (!wrapperConversions.get(subwrapper).isEmpty()) {
- toRemove.add(subwrapper);
- }
- }
- descriptor.removeSubwrappers(toRemove);
- }
- }
-
private static class WrapperDescriptorBuilder {
private final List<DexMethod> methods = new ArrayList<>();
private final List<DexType> subwrappers = new ArrayList<>();
@@ -102,12 +85,6 @@
return new WrapperDescriptor(
ImmutableList.copyOf(methods), ImmutableList.copyOf(subwrappers), nonPublicAccess);
}
-
- public void removeSubwrappers(List<DexType> toRemove) {
- if (!toRemove.isEmpty()) {
- subwrappers.removeAll(toRemove);
- }
- }
}
private Map<DexType, WrapperDescriptorBuilder> initializeDescriptors(