Extend profile rewriting to twr desugaring
Bug: b/265729283
Change-Id: I65c2056c02ea384777fa902b7954c109115284db
diff --git a/src/main/java/com/android/tools/r8/profile/art/rewriting/ArtProfileRewritingCfInstructionDesugaringEventConsumer.java b/src/main/java/com/android/tools/r8/profile/art/rewriting/ArtProfileRewritingCfInstructionDesugaringEventConsumer.java
index 738d12e..2997b23 100644
--- a/src/main/java/com/android/tools/r8/profile/art/rewriting/ArtProfileRewritingCfInstructionDesugaringEventConsumer.java
+++ b/src/main/java/com/android/tools/r8/profile/art/rewriting/ArtProfileRewritingCfInstructionDesugaringEventConsumer.java
@@ -178,6 +178,7 @@
@Override
public void acceptTwrCloseResourceMethod(ProgramMethod closeMethod, ProgramMethod context) {
+ additionsCollection.addRulesIfContextIsInProfile(context, closeMethod, closeMethod.getHolder());
parent.acceptTwrCloseResourceMethod(closeMethod, context);
}
diff --git a/src/test/java/com/android/tools/r8/profile/art/completeness/TwrCloseResourceDuplicationProfileRewritingTest.java b/src/test/java/com/android/tools/r8/profile/art/completeness/TwrCloseResourceDuplicationProfileRewritingTest.java
index 80a799c..692436e 100644
--- a/src/test/java/com/android/tools/r8/profile/art/completeness/TwrCloseResourceDuplicationProfileRewritingTest.java
+++ b/src/test/java/com/android/tools/r8/profile/art/completeness/TwrCloseResourceDuplicationProfileRewritingTest.java
@@ -141,7 +141,6 @@
otherSyntheticTwrCloseResourceClassSubject, notIf(isPresent(), hasTwrCloseResourceSupport));
// Verify that the residual profile contains all of the above.
- // TODO(b/265729283): Profile should include the twr syntehtic methods.
profileInspector
.assertContainsMethodRules(
fooMethodSubject,
@@ -152,10 +151,15 @@
!hasTwrCloseResourceSupport,
i ->
i.assertContainsClassRules(
- syntheticApiOutlineClassSubject, syntheticBackportClassSubject)
+ syntheticApiOutlineClassSubject,
+ syntheticBackportClassSubject,
+ syntheticTwrCloseResourceClassSubject,
+ otherSyntheticTwrCloseResourceClassSubject)
.assertContainsMethodRules(
syntheticApiOutlineClassSubject.uniqueMethod(),
- syntheticBackportClassSubject.uniqueMethod()))
+ syntheticBackportClassSubject.uniqueMethod(),
+ syntheticTwrCloseResourceClassSubject.uniqueMethod(),
+ otherSyntheticTwrCloseResourceClassSubject.uniqueMethod()))
.assertContainsNoOtherRules();
}
}