Desugared lib: stabilize synthetic kind id

Stabilize synthetic kind ids across compiler version
for the synthetic types used in machine specification

Bug: b/262692506
Change-Id: I9ab1671bcc0078c1367bd6d611c792da2211527a
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/DesugaredLibrarySpecificationParser.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/DesugaredLibrarySpecificationParser.java
index bc61d60..8b46407 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/DesugaredLibrarySpecificationParser.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/DesugaredLibrarySpecificationParser.java
@@ -10,7 +10,6 @@
 import com.android.tools.r8.ir.desugar.desugaredlibrary.legacyspecification.LegacyDesugaredLibrarySpecificationParser;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.MachineDesugaredLibrarySpecificationParser;
 import com.android.tools.r8.origin.Origin;
-import com.android.tools.r8.synthesis.SyntheticNaming;
 import com.android.tools.r8.utils.ExceptionDiagnostic;
 import com.android.tools.r8.utils.Reporter;
 import com.android.tools.r8.utils.StringDiagnostic;
@@ -58,7 +57,7 @@
     // It can hardly be written by hand and is always generated.
     if (isMachineSpecification(jsonConfig, reporter, origin)) {
       return new MachineDesugaredLibrarySpecificationParser(
-              dexItemFactory, reporter, libraryCompilation, minAPILevel, new SyntheticNaming())
+              dexItemFactory, reporter, libraryCompilation, minAPILevel)
           .parse(origin, jsonConfigString, jsonConfig);
     }
     // Human Specification is the easy to write format for developers and allows one to widely use
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/DerivedMethod.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/DerivedMethod.java
index dde1f48..714cef4 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/DerivedMethod.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/DerivedMethod.java
@@ -4,10 +4,12 @@
 
 package com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification;
 
+import com.android.tools.r8.graph.AppView;
 import com.android.tools.r8.graph.DexMethod;
 import com.android.tools.r8.graph.DexProto;
 import com.android.tools.r8.graph.DexString;
 import com.android.tools.r8.graph.DexType;
+import com.android.tools.r8.synthesis.SyntheticNaming;
 import com.android.tools.r8.synthesis.SyntheticNaming.SyntheticKind;
 import java.util.Objects;
 
@@ -20,21 +22,29 @@
 public class DerivedMethod implements SpecificationDescriptor {
 
   private final DexMethod method;
-  private final SyntheticKind holderKind;
+  private final MachineSyntheticKind.Kind holderKind;
 
   public DerivedMethod(DexMethod method) {
     this(method, null);
   }
 
-  public DerivedMethod(DexMethod method, SyntheticKind holderKind) {
+  public DerivedMethod(DexMethod method, MachineSyntheticKind.Kind holderKind) {
     this.holderKind = holderKind;
     this.method = method;
   }
 
-  public SyntheticKind getHolderKind() {
+  public MachineSyntheticKind.Kind getMachineHolderKind() {
     return holderKind;
   }
 
+  public SyntheticKind getHolderKind(AppView<?> appView) {
+    return getHolderKind(appView.getSyntheticItems().getNaming());
+  }
+
+  public SyntheticKind getHolderKind(SyntheticNaming naming) {
+    return holderKind == null ? null : holderKind.asSyntheticKind(naming);
+  }
+
   public DexType getHolderContext() {
     return method.getHolderType();
   }
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/MachineDesugaredLibrarySpecificationParser.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/MachineDesugaredLibrarySpecificationParser.java
index 031ca29..0d03018 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/MachineDesugaredLibrarySpecificationParser.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/MachineDesugaredLibrarySpecificationParser.java
@@ -42,8 +42,6 @@
 import com.android.tools.r8.ir.desugar.desugaredlibrary.memberparser.MachineFieldParser;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.memberparser.MachineMethodParser;
 import com.android.tools.r8.origin.Origin;
-import com.android.tools.r8.synthesis.SyntheticNaming;
-import com.android.tools.r8.synthesis.SyntheticNaming.SyntheticKind;
 import com.android.tools.r8.utils.AndroidApiLevel;
 import com.android.tools.r8.utils.DescriptorUtils;
 import com.android.tools.r8.utils.ExceptionDiagnostic;
@@ -74,7 +72,6 @@
   private final Reporter reporter;
   private final boolean libraryCompilation;
   private final int minAPILevel;
-  private final SyntheticNaming syntheticNaming;
 
   private Origin origin;
   private JsonObject jsonConfig;
@@ -84,14 +81,12 @@
       DexItemFactory dexItemFactory,
       Reporter reporter,
       boolean libraryCompilation,
-      int minAPILevel,
-      SyntheticNaming syntheticNaming) {
+      int minAPILevel) {
     this.dexItemFactory = dexItemFactory;
     this.methodParser = new MachineMethodParser(dexItemFactory, this::stringDescriptorToDexType);
     this.fieldParser = new MachineFieldParser(dexItemFactory, this::stringDescriptorToDexType);
     this.reporter = reporter;
     this.minAPILevel = minAPILevel;
-    this.syntheticNaming = syntheticNaming;
     this.libraryCompilation = libraryCompilation;
   }
 
@@ -425,8 +420,7 @@
     if (kind == -1) {
       return new DerivedMethod(dexMethod);
     }
-    SyntheticKind syntheticKind = syntheticNaming.fromId(kind);
-    return new DerivedMethod(dexMethod, syntheticKind);
+    return new DerivedMethod(dexMethod, MachineSyntheticKind.fromId(kind));
   }
 
   private List<DexMethod> parseMethodList(JsonArray array) {
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/MachineSyntheticKind.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/MachineSyntheticKind.java
new file mode 100644
index 0000000..30ae324
--- /dev/null
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/MachineSyntheticKind.java
@@ -0,0 +1,63 @@
+// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification;
+
+import com.android.tools.r8.synthesis.SyntheticNaming;
+import com.android.tools.r8.synthesis.SyntheticNaming.SyntheticKind;
+
+/**
+ * The synthetic kind ids are not stable across compiler version. We need here to have stable ids so
+ * that we can write the machine specification using the id.
+ */
+public class MachineSyntheticKind {
+
+  // These ids should remain stable across compiler versions or it will break machine specification
+  // parsing. The ids chosen were the ids used when generating the 2.0.0 specification (before that
+  // issue was reported in b/262692506).
+  private static final int RETARGET_INTERFACE_ID = 11;
+  private static final int RETARGET_CLASS_ID = 10;
+  private static final int COMPANION_CLASS_ID = 8;
+  private static final int EMULATED_INTERFACE_CLASS_ID = 9;
+
+  public static Kind fromId(int id) {
+    for (Kind kind : Kind.values()) {
+      if (kind.getId() == id) {
+        return kind;
+      }
+    }
+    return null;
+  }
+
+  public enum Kind {
+    RETARGET_INTERFACE(RETARGET_INTERFACE_ID),
+    RETARGET_CLASS(RETARGET_CLASS_ID),
+    COMPANION_CLASS(COMPANION_CLASS_ID),
+    EMULATED_INTERFACE_CLASS(EMULATED_INTERFACE_CLASS_ID);
+
+    private final int id;
+
+    Kind(int id) {
+      this.id = id;
+    }
+
+    public int getId() {
+      return id;
+    }
+
+    public SyntheticKind asSyntheticKind(SyntheticNaming naming) {
+      switch (this) {
+        case RETARGET_INTERFACE:
+          return naming.RETARGET_INTERFACE;
+        case RETARGET_CLASS:
+          return naming.RETARGET_CLASS;
+        case COMPANION_CLASS:
+          return naming.COMPANION_CLASS;
+        case EMULATED_INTERFACE_CLASS:
+          return naming.EMULATED_INTERFACE_CLASS;
+      }
+      return null;
+    }
+  }
+}
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/MultiAPILevelMachineDesugaredLibrarySpecificationJsonExporter.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/MultiAPILevelMachineDesugaredLibrarySpecificationJsonExporter.java
index f5d81fa..c232dff 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/MultiAPILevelMachineDesugaredLibrarySpecificationJsonExporter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/machinespecification/MultiAPILevelMachineDesugaredLibrarySpecificationJsonExporter.java
@@ -315,7 +315,9 @@
     String methodString = toString(derivedMethod.getMethod());
     String holderKindString =
         Integer.toString(
-            derivedMethod.getHolderKind() == null ? -1 : derivedMethod.getHolderKind().getId());
+            derivedMethod.getMachineHolderKind() == null
+                ? -1
+                : derivedMethod.getMachineHolderKind().getId());
     return new Object[] {methodString, holderKindString};
   }
 
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/retargeter/DesugaredLibraryRetargeterSyntheticHelper.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/retargeter/DesugaredLibraryRetargeterSyntheticHelper.java
index 8e6aca3..ae5814a 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/retargeter/DesugaredLibraryRetargeterSyntheticHelper.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/retargeter/DesugaredLibraryRetargeterSyntheticHelper.java
@@ -91,7 +91,7 @@
   }
 
   DexMethod forwardingMethod(EmulatedDispatchMethodDescriptor descriptor) {
-    assert descriptor.getForwardingMethod().getHolderKind() == null;
+    assert descriptor.getForwardingMethod().getHolderKind(appView) == null;
     return descriptor.getForwardingMethod().getMethod();
   }
 
@@ -103,7 +103,7 @@
 
   private boolean verifyKind(DerivedMethod method, SyntheticKindSelector kindSelector) {
     SyntheticKind kind = kindSelector.select(appView.getSyntheticItems().getNaming());
-    assert method.getHolderKind().equals(kind);
+    assert method.getHolderKind(appView).equals(kind);
     return true;
   }
 
@@ -139,7 +139,7 @@
           appView
               .getSyntheticItems()
               .getExistingFixedClass(
-                  ignored -> emulatedDispatchMethod.getHolderKind(), holderContext, appView);
+                  ignored -> emulatedDispatchMethod.getHolderKind(appView), holderContext, appView);
       DexMethod dispatchMethod =
           emulatedHolderDispatchMethod(syntheticClass.type, emulatedDispatchMethod);
       assert syntheticClass.lookupMethod(dispatchMethod) != null;
@@ -177,7 +177,7 @@
     appView
         .getSyntheticItems()
         .ensureFixedClass(
-            ignored -> emulatedDispatchMethod.getHolderKind(),
+            ignored -> emulatedDispatchMethod.getHolderKind(appView),
             holderContext,
             appView,
             classBuilder -> buildHolderDispatchMethod(classBuilder, itfClass, descriptor, null),
@@ -193,7 +193,7 @@
     if (appView.options().isDesugaredLibraryCompilation()) {
       return appView
           .getSyntheticItems()
-          .getExistingFixedClass(ignored -> itfMethod.getHolderKind(), itfContext, appView);
+          .getExistingFixedClass(ignored -> itfMethod.getHolderKind(appView), itfContext, appView);
     }
     ClasspathOrLibraryClass context = itfContext.asClasspathOrLibraryClass();
     assert context != null;
@@ -217,7 +217,7 @@
     return appView
         .getSyntheticItems()
         .ensureFixedClass(
-            ignore -> itfMethod.getHolderKind(),
+            ignore -> itfMethod.getHolderKind(appView),
             itfContext,
             appView,
             classBuilder -> buildInterfaceDispatchMethod(classBuilder, descriptor),
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineEmulatedInterfaceConverter.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineEmulatedInterfaceConverter.java
index 00c7da1..15c644b 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineEmulatedInterfaceConverter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineEmulatedInterfaceConverter.java
@@ -16,7 +16,7 @@
 import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.EmulatedDispatchMethodDescriptor;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.EmulatedInterfaceDescriptor;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.MachineRewritingFlags;
-import com.android.tools.r8.synthesis.SyntheticNaming;
+import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.MachineSyntheticKind;
 import com.android.tools.r8.utils.WorkList;
 import com.google.common.collect.Sets;
 import java.util.ArrayList;
@@ -68,8 +68,8 @@
 
   private EmulatedDispatchMethodDescriptor computeEmulatedDispatchDescriptor(
       DexMethod method, HumanRewritingFlags rewritingFlags, AppInfoWithClassHierarchy appInfo) {
-    SyntheticNaming syntheticNaming = appInfo.getSyntheticItems().getNaming();
-    DerivedMethod forwardingMethod = new DerivedMethod(method, syntheticNaming.COMPANION_CLASS);
+    DerivedMethod forwardingMethod =
+        new DerivedMethod(method, MachineSyntheticKind.Kind.COMPANION_CLASS);
     DexMethod itfDexMethod =
         appInfo
             .dexItemFactory()
@@ -79,7 +79,7 @@
                 method.getName());
     DerivedMethod interfaceMethod = new DerivedMethod(itfDexMethod);
     DerivedMethod dispatchMethod =
-        new DerivedMethod(method, syntheticNaming.EMULATED_INTERFACE_CLASS);
+        new DerivedMethod(method, MachineSyntheticKind.Kind.EMULATED_INTERFACE_CLASS);
     LinkedHashMap<DexType, DerivedMethod> dispatchCases = getDispatchCases(rewritingFlags, method);
     return new EmulatedDispatchMethodDescriptor(
         interfaceMethod, dispatchMethod, forwardingMethod, dispatchCases);
@@ -110,7 +110,6 @@
       }
     }
     if (subInterfaces != null) {
-      SyntheticNaming syntheticNaming = appInfo.getSyntheticItems().getNaming();
       for (int i = subInterfaces.size() - 1; i >= 0; i--) {
         DexClass subInterfaceClass = appInfo.definitionFor(subInterfaces.get(i));
         assert subInterfaceClass != null;
@@ -122,7 +121,7 @@
           DexMethod reference = result.getReference();
           extraDispatchCases.put(
               subInterfaceClass.type,
-              new DerivedMethod(reference, syntheticNaming.COMPANION_CLASS));
+              new DerivedMethod(reference, MachineSyntheticKind.Kind.COMPANION_CLASS));
         }
       }
     } else {
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineRetargetConverter.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineRetargetConverter.java
index 004c35f..1197688 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineRetargetConverter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/specificationconversion/HumanToMachineRetargetConverter.java
@@ -17,7 +17,7 @@
 import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.DerivedMethod;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.EmulatedDispatchMethodDescriptor;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.MachineRewritingFlags;
-import com.android.tools.r8.synthesis.SyntheticNaming;
+import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.MachineSyntheticKind;
 import com.android.tools.r8.utils.TraversalContinuation;
 import com.google.common.collect.Sets;
 import java.util.LinkedHashMap;
@@ -220,12 +220,11 @@
       return;
     }
     // TODO(b/184026720): Implement library boundaries.
-    SyntheticNaming syntheticNaming = appInfo.getSyntheticItems().getNaming();
     DerivedMethod forwardingMethod = new DerivedMethod(forwardingDexMethod);
     DerivedMethod interfaceMethod =
-        new DerivedMethod(src.getReference(), syntheticNaming.RETARGET_INTERFACE);
+        new DerivedMethod(src.getReference(), MachineSyntheticKind.Kind.RETARGET_INTERFACE);
     DerivedMethod dispatchMethod =
-        new DerivedMethod(src.getReference(), syntheticNaming.RETARGET_CLASS);
+        new DerivedMethod(src.getReference(), MachineSyntheticKind.Kind.RETARGET_CLASS);
     LinkedHashMap<DexType, DerivedMethod> dispatchCases = new LinkedHashMap<>();
     builder.putEmulatedVirtualRetarget(
         src.getReference(),
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/itf/InterfaceDesugaringSyntheticHelper.java b/src/main/java/com/android/tools/r8/ir/desugar/itf/InterfaceDesugaringSyntheticHelper.java
index 4ac2b73..0fa2592 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/itf/InterfaceDesugaringSyntheticHelper.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/itf/InterfaceDesugaringSyntheticHelper.java
@@ -147,7 +147,7 @@
 
   public boolean verifyKind(DerivedMethod method, SyntheticKindSelector kindSelector) {
     SyntheticKind kind = kindSelector.select(appView.getSyntheticItems().getNaming());
-    assert method.getHolderKind().equals(kind);
+    assert method.getHolderKind(appView).equals(kind);
     return true;
   }
 
@@ -158,7 +158,7 @@
   }
 
   DexMethod emulatedInterfaceInterfaceMethod(DerivedMethod method) {
-    assert method.getHolderKind() == null;
+    assert method.getHolderKind(appView) == null;
     return method.getMethod();
   }
 
@@ -275,7 +275,7 @@
   }
 
   DexMethod ensureEmulatedInterfaceForwardingMethod(DerivedMethod method) {
-    if (method.getHolderKind() == null) {
+    if (method.getHolderKind(appView) == null) {
       return method.getMethod();
     }
     assert verifyKind(method, kinds -> kinds.COMPANION_CLASS);
diff --git a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/specification/ConvertExportReadTest.java b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/specification/ConvertExportReadTest.java
index a66e6b4..53ffbd1 100644
--- a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/specification/ConvertExportReadTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/specification/ConvertExportReadTest.java
@@ -36,7 +36,6 @@
 import com.android.tools.r8.ir.desugar.desugaredlibrary.specificationconversion.HumanToMachineSpecificationConverter;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.specificationconversion.LegacyToHumanSpecificationConverter;
 import com.android.tools.r8.origin.Origin;
-import com.android.tools.r8.synthesis.SyntheticNaming;
 import com.android.tools.r8.utils.AndroidApiLevel;
 import com.android.tools.r8.utils.Box;
 import com.android.tools.r8.utils.InternalOptions;
@@ -102,11 +101,7 @@
 
     MachineDesugaredLibrarySpecification machineSpecParsed =
         new MachineDesugaredLibrarySpecificationParser(
-                options.dexItemFactory(),
-                options.reporter,
-                true,
-                AndroidApiLevel.B.getLevel(),
-                new SyntheticNaming())
+                options.dexItemFactory(), options.reporter, true, AndroidApiLevel.B.getLevel())
             .parse(StringResource.fromString(json2.get(), Origin.unknown()));
     assertFalse(machineSpecParsed.getRewriteType().isEmpty());
   }
@@ -129,22 +124,6 @@
     InternalOptions options = new InternalOptions();
 
     Path output = temp.newFile().toPath();
-    convertMultiLevelAnythingToMachineSpecification(spec, output, options);
-
-    MachineDesugaredLibrarySpecification machineSpecParsed =
-        new MachineDesugaredLibrarySpecificationParser(
-                options.dexItemFactory(),
-                options.reporter,
-                true,
-                AndroidApiLevel.B.getLevel(),
-                new SyntheticNaming())
-            .parse(StringResource.fromFile(output));
-    assertFalse(machineSpecParsed.getRewriteType().isEmpty());
-  }
-
-  public void convertMultiLevelAnythingToMachineSpecification(
-      LibraryDesugaringSpecification spec, Path output, InternalOptions options)
-      throws IOException {
 
     MultiAPILevelHumanDesugaredLibrarySpecification humanSpec =
         DesugaredLibraryConverter.convertMultiLevelAnythingToMachineSpecification(
@@ -154,6 +133,12 @@
             output,
             options);
 
+    MachineDesugaredLibrarySpecification machineSpecParsed =
+        new MachineDesugaredLibrarySpecificationParser(
+                options.dexItemFactory(), options.reporter, true, AndroidApiLevel.B.getLevel())
+            .parse(StringResource.fromFile(output));
+    assertFalse(machineSpecParsed.getRewriteType().isEmpty());
+
     if (humanSpec == null) {
       return;
     }
@@ -167,6 +152,19 @@
                 options.dexItemFactory(), options.reporter)
             .parseMultiLevelConfiguration(StringResource.fromString(json.get(), Origin.unknown()));
     assertSpecEquals(humanSpec, writtenHumanSpec);
+
+    // Validate converted machine spec is identical to the written one.
+    HumanDesugaredLibrarySpecification humanSimpleSpec =
+        new HumanDesugaredLibrarySpecificationParser(
+                options.dexItemFactory(), options.reporter, true, AndroidApiLevel.B.getLevel())
+            .parse(StringResource.fromString(json.get(), Origin.unknown()));
+    HumanToMachineSpecificationConverter converter =
+        new HumanToMachineSpecificationConverter(Timing.empty());
+    DexApplication app = spec.getAppForTesting(options, true);
+    MachineDesugaredLibrarySpecification machineSimpleSpec =
+        converter.convert(humanSimpleSpec, app);
+
+    assertSpecEquals(machineSimpleSpec, machineSpecParsed);
   }
 
   @Test
@@ -196,11 +194,7 @@
         new AndroidApiLevel[] {AndroidApiLevel.B, AndroidApiLevel.N, AndroidApiLevel.O}) {
       MachineDesugaredLibrarySpecification machineSpecParsed =
           new MachineDesugaredLibrarySpecificationParser(
-                  options.dexItemFactory(),
-                  options.reporter,
-                  true,
-                  api.getLevel(),
-                  new SyntheticNaming())
+                  options.dexItemFactory(), options.reporter, true, api.getLevel())
               .parse(StringResource.fromString(json2.get(), Origin.unknown()));
 
       HumanDesugaredLibrarySpecification humanSpecB =