Fix R8 not writing nest annotations when inner class info is not kept

Bug: b/130716228
Bug: b/236125275
Change-Id: I2cd7c020a8e4c200fc7e53503d134efe4dd9f070
diff --git a/src/main/java/com/android/tools/r8/dex/ApplicationWriter.java b/src/main/java/com/android/tools/r8/dex/ApplicationWriter.java
index 5f0d225..4300df0 100644
--- a/src/main/java/com/android/tools/r8/dex/ApplicationWriter.java
+++ b/src/main/java/com/android/tools/r8/dex/ApplicationWriter.java
@@ -769,7 +769,8 @@
     List<InnerClassAttribute> innerClasses = clazz.getInnerClasses();
     if (enclosingMethod == null
         && innerClasses.isEmpty()
-        && clazz.getClassSignature().hasNoSignature()) {
+        && clazz.getClassSignature().hasNoSignature()
+        && !clazz.isInANest()) {
       return;
     }
 
diff --git a/src/test/java/com/android/tools/r8/desugar/nestaccesscontrol/NestAttributesInDexShrinkingTest.java b/src/test/java/com/android/tools/r8/desugar/nestaccesscontrol/NestAttributesInDexShrinkingTest.java
index 8e74901..9829235 100644
--- a/src/test/java/com/android/tools/r8/desugar/nestaccesscontrol/NestAttributesInDexShrinkingTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/nestaccesscontrol/NestAttributesInDexShrinkingTest.java
@@ -69,12 +69,7 @@
   }
 
   private void expectNestAttributes(CodeInspector inspector) {
-    if (parameters.isCfRuntime()) {
-      inspect(inspector, true);
-    } else {
-      // TODO(b/236125275): DEX should also have the nest attributes.
-      expectNoNestAttributes(inspector);
-    }
+    inspect(inspector, true);
   }
 
   private void expectNoNestAttributes(CodeInspector inspector) {