Reorder and cleanup post processing desugarings
Change-Id: I9ba921338cad07de267c049e854100fa68d2fe29
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/CfPostProcessingDesugaringCollection.java b/src/main/java/com/android/tools/r8/ir/desugar/CfPostProcessingDesugaringCollection.java
index a054501..87ee48f 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/CfPostProcessingDesugaringCollection.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/CfPostProcessingDesugaringCollection.java
@@ -85,23 +85,19 @@
InterfaceMethodProcessorFacade interfaceMethodProcessorFacade,
Enqueuer enqueuer) {
ArrayList<CfPostProcessingDesugaring> desugarings = new ArrayList<>();
- if (isLibraryDesugaringEnabled(appView, enqueuer)) {
- addIfNotNull(desugarings, DesugaredLibraryRetargeterPostProcessor.create(appView));
- }
- if (isNormalDesugaringEnabled(appView, enqueuer)) {
- addIfNotNull(desugarings, AutoCloseableRetargeterPostProcessor.create(appView));
- }
addIfNotNull(desugarings, interfaceMethodProcessorFacade);
if (isLibraryDesugaringEnabled(appView, enqueuer)) {
addIfNotNull(
desugarings,
- DesugaredLibraryApiCallbackSynthesizerPostProcessor.create(appView, enqueuer));
+ DesugaredLibraryApiCallbackSynthesizerPostProcessor.create(appView, enqueuer),
+ DesugaredLibraryDisableDesugarerPostProcessor.create(appView),
+ DesugaredLibraryRetargeterPostProcessor.create(appView));
}
if (isNormalDesugaringEnabled(appView, enqueuer)) {
- addIfNotNull(desugarings, RecordClassDesugaringPostProcessor.create(appView));
- }
- if (isLibraryDesugaringEnabled(appView, enqueuer)) {
- addIfNotNull(desugarings, DesugaredLibraryDisableDesugarerPostProcessor.create(appView));
+ addIfNotNull(
+ desugarings,
+ AutoCloseableRetargeterPostProcessor.create(appView),
+ RecordClassDesugaringPostProcessor.create(appView));
}
return desugarings.isEmpty()
? empty()
@@ -109,9 +105,12 @@
}
private static void addIfNotNull(
- Collection<CfPostProcessingDesugaring> collection, CfPostProcessingDesugaring desugaring) {
- if (desugaring != null) {
- collection.add(desugaring);
+ Collection<CfPostProcessingDesugaring> collection,
+ CfPostProcessingDesugaring... desugarings) {
+ for (CfPostProcessingDesugaring desugaring : desugarings) {
+ if (desugaring != null) {
+ collection.add(desugaring);
+ }
}
}