Remove support for legacy synthetics

Bug: 158159959
Bug: 165224388
Bug: 175542052
Change-Id: I5df8501608d6b5c848439db389bd4f1904f57cf1
diff --git a/src/main/java/com/android/tools/r8/features/ClassToFeatureSplitMap.java b/src/main/java/com/android/tools/r8/features/ClassToFeatureSplitMap.java
index f460b50..7fa12ce 100644
--- a/src/main/java/com/android/tools/r8/features/ClassToFeatureSplitMap.java
+++ b/src/main/java/com/android/tools/r8/features/ClassToFeatureSplitMap.java
@@ -45,11 +45,6 @@
   }
 
   public static ClassToFeatureSplitMap createInitialClassToFeatureSplitMap(
-      AppView<? extends AppInfoWithClassHierarchy> appView) {
-    return createInitialClassToFeatureSplitMap(appView.options());
-  }
-
-  public static ClassToFeatureSplitMap createInitialClassToFeatureSplitMap(
       InternalOptions options) {
     return createInitialClassToFeatureSplitMap(
         options.dexItemFactory(), options.featureSplitConfiguration, options.reporter);
@@ -59,7 +54,6 @@
       DexItemFactory dexItemFactory,
       FeatureSplitConfiguration featureSplitConfiguration,
       Reporter reporter) {
-
     ClassToFeatureSplitMap result = new ClassToFeatureSplitMap();
     if (featureSplitConfiguration == null) {
       return result;
diff --git a/src/main/java/com/android/tools/r8/graph/AppInfo.java b/src/main/java/com/android/tools/r8/graph/AppInfo.java
index e5a744b..41551f4 100644
--- a/src/main/java/com/android/tools/r8/graph/AppInfo.java
+++ b/src/main/java/com/android/tools/r8/graph/AppInfo.java
@@ -125,26 +125,6 @@
     return syntheticItems;
   }
 
-  public void addSynthesizedClassForLibraryDesugaring(DexProgramClass clazz) {
-    assert checkIfObsolete();
-    assert options().desugaredLibraryConfiguration != null;
-    syntheticItems.addLegacySyntheticClassForLibraryDesugaring(clazz);
-  }
-
-  public void addSynthesizedClass(DexProgramClass clazz, ProgramDefinition context) {
-    assert checkIfObsolete();
-    assert context != null;
-    syntheticItems.addLegacySyntheticClass(clazz, context, FeatureSplit.BASE);
-  }
-
-  public void addSynthesizedClassToBase(DexProgramClass clazz, Iterable<DexProgramClass> contexts) {
-    assert checkIfObsolete();
-    assert !IterableUtils.isEmpty(contexts);
-    SyntheticItems syntheticItems = getSyntheticItems();
-    contexts.forEach(
-        context -> syntheticItems.addLegacySyntheticClass(clazz, context, FeatureSplit.BASE));
-  }
-
   public List<DexProgramClass> classes() {
     assert checkIfObsolete();
     return app.classes();
diff --git a/src/main/java/com/android/tools/r8/graph/AppInfoWithClassHierarchy.java b/src/main/java/com/android/tools/r8/graph/AppInfoWithClassHierarchy.java
index 4eaea9f..9aa49f7 100644
--- a/src/main/java/com/android/tools/r8/graph/AppInfoWithClassHierarchy.java
+++ b/src/main/java/com/android/tools/r8/graph/AppInfoWithClassHierarchy.java
@@ -161,15 +161,6 @@
     return this;
   }
 
-  @Override
-  public void addSynthesizedClass(DexProgramClass clazz, ProgramDefinition context) {
-    assert checkIfObsolete();
-    assert context != null;
-    FeatureSplit featureSplit =
-        classToFeatureSplitMap.getFeatureSplit(context, getSyntheticItems());
-    getSyntheticItems().addLegacySyntheticClass(clazz, context, featureSplit);
-  }
-
   /** Primitive traversal over all (non-interface) superclasses of a given type. */
   public TraversalContinuation traverseSuperClasses(
       DexClass clazz, TriFunction<DexType, DexClass, DexClass, TraversalContinuation> fn) {
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java b/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
index 37ce381..9e2c3a2 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
@@ -819,20 +819,9 @@
 
     // Assure that no more optimization feedback left after post processing.
     assert feedback.noUpdatesLeft();
-    assert checkLegacySyntheticsAreInBuilder(appView, builder);
     return builder.build();
   }
 
-  private boolean checkLegacySyntheticsAreInBuilder(
-      AppView<AppInfoWithLiveness> appView, Builder<?> builder) {
-    Collection<DexProgramClass> inAppInfo =
-        appView.appInfo().getSyntheticItems().getLegacyPendingClasses();
-    Collection<DexProgramClass> inBuilder = builder.getSynthesizedClasses();
-    assert inAppInfo.containsAll(inBuilder);
-    assert inBuilder.containsAll(inAppInfo);
-    return true;
-  }
-
   private void waveStart(ProgramMethodSet wave) {
     onWaveDoneActions = Collections.synchronizedList(new ArrayList<>());
   }
diff --git a/src/main/java/com/android/tools/r8/shaking/AppInfoWithLiveness.java b/src/main/java/com/android/tools/r8/shaking/AppInfoWithLiveness.java
index 3bd0c98..c34f7f3 100644
--- a/src/main/java/com/android/tools/r8/shaking/AppInfoWithLiveness.java
+++ b/src/main/java/com/android/tools/r8/shaking/AppInfoWithLiveness.java
@@ -979,10 +979,7 @@
   private boolean isInstantiatedDirectly(DexProgramClass clazz) {
     assert checkIfObsolete();
     DexType type = clazz.type;
-    return
-    // TODO(b/165224388): Synthetic classes should be represented in the allocation info.
-    getSyntheticItems().isLegacySyntheticClass(clazz)
-        || (!clazz.isInterface() && objectAllocationInfoCollection.isInstantiatedDirectly(clazz))
+    return (!clazz.isInterface() && objectAllocationInfoCollection.isInstantiatedDirectly(clazz))
         // TODO(b/145344105): Model annotations in the object allocation info.
         || (clazz.isAnnotation() && liveTypes.contains(type));
   }
@@ -1274,7 +1271,7 @@
         getClassToFeatureSplitMap().rewrittenWithLens(lens),
         getMainDexInfo().rewrittenWithLens(getSyntheticItems(), lens),
         deadProtoTypes,
-        getMissingClasses().commitSyntheticItems(committedItems),
+        getMissingClasses(),
         lens.rewriteReferences(liveTypes),
         lens.rewriteReferences(targetedMethods),
         lens.rewriteReferences(failedMethodResolutionTargets),
diff --git a/src/main/java/com/android/tools/r8/shaking/MissingClasses.java b/src/main/java/com/android/tools/r8/shaking/MissingClasses.java
index ac8f1fb..b5d7329 100644
--- a/src/main/java/com/android/tools/r8/shaking/MissingClasses.java
+++ b/src/main/java/com/android/tools/r8/shaking/MissingClasses.java
@@ -51,13 +51,6 @@
     return new MissingClasses(Sets.newIdentityHashSet());
   }
 
-  public MissingClasses commitSyntheticItems(CommittedItems committedItems) {
-    return builder()
-        // TODO(b/175542052): Synthetic types should not be reported as missing in the first place.
-        .removeAlreadyMissingClasses(committedItems.getLegacySyntheticTypes())
-        .build();
-  }
-
   public void forEach(Consumer<DexType> missingClassConsumer) {
     missingClasses.forEach(missingClassConsumer);
   }
diff --git a/src/main/java/com/android/tools/r8/synthesis/CommittedItems.java b/src/main/java/com/android/tools/r8/synthesis/CommittedItems.java
index f71c94e..1e4071f 100644
--- a/src/main/java/com/android/tools/r8/synthesis/CommittedItems.java
+++ b/src/main/java/com/android/tools/r8/synthesis/CommittedItems.java
@@ -54,11 +54,6 @@
     return committedProgramTypes;
   }
 
-  @Deprecated
-  public Collection<DexType> getLegacySyntheticTypes() {
-    return committed.getLegacyTypes().keySet();
-  }
-
   @Override
   public DexClass definitionFor(DexType type, Function<DexType, DexClass> baseDefinitionFor) {
     // All synthetic types are committed to the application so lookup is just the base lookup.
diff --git a/src/main/java/com/android/tools/r8/synthesis/CommittedSyntheticsCollection.java b/src/main/java/com/android/tools/r8/synthesis/CommittedSyntheticsCollection.java
index fd7437e..6961fb0 100644
--- a/src/main/java/com/android/tools/r8/synthesis/CommittedSyntheticsCollection.java
+++ b/src/main/java/com/android/tools/r8/synthesis/CommittedSyntheticsCollection.java
@@ -34,7 +34,6 @@
     private final CommittedSyntheticsCollection parent;
     private Map<DexType, List<SyntheticProgramClassReference>> newNonLegacyClasses = null;
     private Map<DexType, List<SyntheticMethodReference>> newNonLegacyMethods = null;
-    private Map<DexType, List<LegacySyntheticReference>> newLegacyClasses = null;
     private ImmutableSet.Builder<DexType> newSyntheticInputs = null;
 
     public Builder(CommittedSyntheticsCollection parent) {
@@ -76,28 +75,6 @@
       return this;
     }
 
-    public Builder addLegacyClasses(Map<DexType, LegacySyntheticDefinition> classes) {
-      if (newLegacyClasses == null) {
-        newLegacyClasses = new IdentityHashMap<>();
-      }
-      classes.forEach(
-          (type, item) ->
-              newLegacyClasses
-                  .computeIfAbsent(type, ignore -> new ArrayList<>())
-                  .add(item.toReference()));
-      return this;
-    }
-
-    public Builder addLegacyClass(LegacySyntheticReference reference) {
-      if (newLegacyClasses == null) {
-        newLegacyClasses = new IdentityHashMap<>();
-      }
-      newLegacyClasses
-          .computeIfAbsent(reference.getHolder(), ignore -> new ArrayList<>())
-          .add(reference);
-      return this;
-    }
-
     public Builder addSyntheticInput(DexType syntheticInput) {
       if (newSyntheticInputs == null) {
         newSyntheticInputs = ImmutableSet.builder();
@@ -116,26 +93,21 @@
       if (newNonLegacyMethods != null) {
         newSyntheticInputs.addAll(newNonLegacyMethods.keySet());
       }
-      if (newLegacyClasses != null) {
-        newSyntheticInputs.addAll(newLegacyClasses.keySet());
-      }
       return this;
     }
 
     public CommittedSyntheticsCollection build() {
-      if (newNonLegacyClasses == null && newNonLegacyMethods == null && newLegacyClasses == null) {
+      if (newNonLegacyClasses == null && newNonLegacyMethods == null) {
         return parent;
       }
       ImmutableMap<DexType, List<SyntheticProgramClassReference>> allNonLegacyClasses =
           merge(newNonLegacyClasses, parent.nonLegacyClasses);
       ImmutableMap<DexType, List<SyntheticMethodReference>> allNonLegacyMethods =
           merge(newNonLegacyMethods, parent.nonLegacyMethods);
-      ImmutableMap<DexType, List<LegacySyntheticReference>> allLegacyClasses =
-          merge(newLegacyClasses, parent.legacyTypes);
       ImmutableSet<DexType> allSyntheticInputs =
           newSyntheticInputs == null ? parent.syntheticInputs : newSyntheticInputs.build();
       return new CommittedSyntheticsCollection(
-          allLegacyClasses, allNonLegacyMethods, allNonLegacyClasses, allSyntheticInputs);
+          allNonLegacyMethods, allNonLegacyClasses, allSyntheticInputs);
     }
   }
 
@@ -151,15 +123,7 @@
   }
 
   private static final CommittedSyntheticsCollection EMPTY =
-      new CommittedSyntheticsCollection(
-          ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableSet.of());
-
-  /**
-   * Immutable set of synthetic types in the application (eg, committed).
-   *
-   * <p>TODO(b/158159959): Remove legacy support.
-   */
-  private final ImmutableMap<DexType, List<LegacySyntheticReference>> legacyTypes;
+      new CommittedSyntheticsCollection(ImmutableMap.of(), ImmutableMap.of(), ImmutableSet.of());
 
   /** Mapping from synthetic type to its synthetic method item description. */
   private final ImmutableMap<DexType, List<SyntheticMethodReference>> nonLegacyMethods;
@@ -171,11 +135,9 @@
   public final ImmutableSet<DexType> syntheticInputs;
 
   public CommittedSyntheticsCollection(
-      ImmutableMap<DexType, List<LegacySyntheticReference>> legacyTypes,
       ImmutableMap<DexType, List<SyntheticMethodReference>> nonLegacyMethods,
       ImmutableMap<DexType, List<SyntheticProgramClassReference>> nonLegacyClasses,
       ImmutableSet<DexType> syntheticInputs) {
-    this.legacyTypes = legacyTypes;
     this.nonLegacyMethods = nonLegacyMethods;
     this.nonLegacyClasses = nonLegacyClasses;
     this.syntheticInputs = syntheticInputs;
@@ -185,7 +147,6 @@
   private boolean verifySyntheticInputsSubsetOfSynthetics() {
     Set<DexType> synthetics =
         ImmutableSet.<DexType>builder()
-            .addAll(legacyTypes.keySet())
             .addAll(nonLegacyMethods.keySet())
             .addAll(nonLegacyClasses.keySet())
             .build();
@@ -206,14 +167,13 @@
   }
 
   boolean isEmpty() {
-    boolean empty =
-        legacyTypes.isEmpty() && nonLegacyMethods.isEmpty() && nonLegacyClasses.isEmpty();
+    boolean empty = nonLegacyMethods.isEmpty() && nonLegacyClasses.isEmpty();
     assert !empty || syntheticInputs.isEmpty();
     return empty;
   }
 
   boolean containsType(DexType type) {
-    return containsLegacyType(type) || containsNonLegacyType(type);
+    return containsNonLegacyType(type);
   }
 
   boolean containsTypeOfKind(DexType type, SyntheticKind kind) {
@@ -229,10 +189,6 @@
     return false;
   }
 
-  public boolean containsLegacyType(DexType type) {
-    return legacyTypes.containsKey(type);
-  }
-
   public boolean containsNonLegacyType(DexType type) {
     return nonLegacyMethods.containsKey(type) || nonLegacyClasses.containsKey(type);
   }
@@ -241,14 +197,6 @@
     return syntheticInputs.contains(type);
   }
 
-  public ImmutableMap<DexType, List<LegacySyntheticReference>> getLegacyTypes() {
-    return legacyTypes;
-  }
-
-  public List<LegacySyntheticReference> getLegacyTypes(DexType type) {
-    return legacyTypes.getOrDefault(type, emptyList());
-  }
-
   public ImmutableMap<DexType, List<SyntheticMethodReference>> getNonLegacyMethods() {
     return nonLegacyMethods;
   }
@@ -279,13 +227,6 @@
     }
     Builder builder = CommittedSyntheticsCollection.empty().builder();
     boolean changed = false;
-    for (LegacySyntheticReference reference : IterableUtils.flatten(legacyTypes.values())) {
-      if (removed.contains(reference.getHolder())) {
-        changed = true;
-      } else {
-        builder.addLegacyClass(reference);
-      }
-    }
     for (SyntheticMethodReference reference : IterableUtils.flatten(nonLegacyMethods.values())) {
       if (removed.contains(reference.getHolder())) {
         changed = true;
@@ -314,7 +255,6 @@
   CommittedSyntheticsCollection rewriteWithLens(NonIdentityGraphLens lens) {
     ImmutableSet.Builder<DexType> syntheticInputsBuilder = ImmutableSet.builder();
     return new CommittedSyntheticsCollection(
-        rewriteItems(legacyTypes, lens, syntheticInputsBuilder),
         rewriteItems(nonLegacyMethods, lens, syntheticInputsBuilder),
         rewriteItems(nonLegacyClasses, lens, syntheticInputsBuilder),
         syntheticInputsBuilder.build());
@@ -340,7 +280,6 @@
   }
 
   boolean verifyTypesAreInApp(DexApplication application) {
-    assert verifyTypesAreInApp(application, legacyTypes.keySet());
     assert verifyTypesAreInApp(application, nonLegacyMethods.keySet());
     assert verifyTypesAreInApp(application, nonLegacyClasses.keySet());
     assert verifyTypesAreInApp(application, syntheticInputs);
diff --git a/src/main/java/com/android/tools/r8/synthesis/LegacySyntheticDefinition.java b/src/main/java/com/android/tools/r8/synthesis/LegacySyntheticDefinition.java
deleted file mode 100644
index 3e50bf5..0000000
--- a/src/main/java/com/android/tools/r8/synthesis/LegacySyntheticDefinition.java
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2021, 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.synthesis;
-
-import com.android.tools.r8.FeatureSplit;
-import com.android.tools.r8.graph.DexProgramClass;
-import com.android.tools.r8.graph.DexType;
-import com.android.tools.r8.graph.ProgramDefinition;
-import com.android.tools.r8.utils.IterableUtils;
-import com.google.common.collect.ImmutableSet;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class LegacySyntheticDefinition {
-  private final DexProgramClass clazz;
-  private final Map<DexType, FeatureSplit> contexts = new ConcurrentHashMap<>();
-
-  public LegacySyntheticDefinition(DexProgramClass clazz) {
-    this.clazz = clazz;
-  }
-
-  public void addContext(ProgramDefinition clazz, FeatureSplit featureSplit) {
-    DexType type = clazz.getContextType();
-    contexts.put(type, featureSplit);
-  }
-
-  public Set<DexType> getContexts() {
-    return contexts.keySet();
-  }
-
-  public LegacySyntheticReference toReference() {
-    return new LegacySyntheticReference(
-        clazz.getType(), ImmutableSet.copyOf(contexts.keySet()), getFeatureSplit());
-  }
-
-  public FeatureSplit getFeatureSplit() {
-    assert verifyConsistentFeatures();
-    if (contexts.isEmpty()) {
-      return FeatureSplit.BASE;
-    }
-    return IterableUtils.first(contexts.values());
-  }
-
-  private boolean verifyConsistentFeatures() {
-    HashSet<FeatureSplit> features = new HashSet<>(contexts.values());
-    assert features.size() < 2;
-    return true;
-  }
-
-  public DexProgramClass getDefinition() {
-    return clazz;
-  }
-}
diff --git a/src/main/java/com/android/tools/r8/synthesis/LegacySyntheticReference.java b/src/main/java/com/android/tools/r8/synthesis/LegacySyntheticReference.java
deleted file mode 100644
index 715e790..0000000
--- a/src/main/java/com/android/tools/r8/synthesis/LegacySyntheticReference.java
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2021, 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.synthesis;
-
-import com.android.tools.r8.FeatureSplit;
-import com.android.tools.r8.graph.DexType;
-import com.android.tools.r8.graph.GraphLens.NonIdentityGraphLens;
-import java.util.Set;
-
-public class LegacySyntheticReference implements Rewritable<LegacySyntheticReference> {
-  private final DexType type;
-  private final Set<DexType> contexts;
-  private final FeatureSplit featureSplit;
-
-  public LegacySyntheticReference(DexType type, Set<DexType> contexts, FeatureSplit featureSplit) {
-    this.type = type;
-    this.contexts = contexts;
-    this.featureSplit = featureSplit;
-  }
-
-  @Override
-  public DexType getHolder() {
-    return type;
-  }
-
-  public Set<DexType> getContexts() {
-    return contexts;
-  }
-
-  public FeatureSplit getFeatureSplit() {
-    return featureSplit;
-  }
-
-  @Override
-  public LegacySyntheticReference rewrite(NonIdentityGraphLens lens) {
-    DexType rewrittenType = lens.lookupType(type);
-    Set<DexType> rewrittenContexts = lens.rewriteTypes(getContexts());
-    if (type == rewrittenType && contexts.equals(rewrittenContexts)) {
-      return this;
-    }
-    return new LegacySyntheticReference(rewrittenType, rewrittenContexts, featureSplit);
-  }
-}
diff --git a/src/main/java/com/android/tools/r8/synthesis/SyntheticFinalization.java b/src/main/java/com/android/tools/r8/synthesis/SyntheticFinalization.java
index 0ce464d..9548f78 100644
--- a/src/main/java/com/android/tools/r8/synthesis/SyntheticFinalization.java
+++ b/src/main/java/com/android/tools/r8/synthesis/SyntheticFinalization.java
@@ -269,8 +269,7 @@
         new CommittedItems(
             SyntheticItems.INVALID_ID_AFTER_SYNTHETIC_FINALIZATION,
             application,
-            new CommittedSyntheticsCollection(
-                committed.getLegacyTypes(), finalMethods, finalClasses, finalInputSynthetics),
+            new CommittedSyntheticsCollection(finalMethods, finalClasses, finalInputSynthetics),
             ImmutableList.of()),
         syntheticFinalizationGraphLens,
         PrunedItems.builder().setPrunedApp(application).addRemovedClasses(prunedSynthetics).build(),
@@ -330,13 +329,6 @@
   private boolean verifyOneSyntheticPerSyntheticClass() {
     Set<DexType> seen = Sets.newIdentityHashSet();
     committed
-        .getLegacyTypes()
-        .forEach(
-            (type, references) -> {
-              assert seen.add(type);
-              assert references.size() == 1;
-            });
-    committed
         .getNonLegacyClasses()
         .forEach(
             (type, references) -> {
diff --git a/src/main/java/com/android/tools/r8/synthesis/SyntheticItems.java b/src/main/java/com/android/tools/r8/synthesis/SyntheticItems.java
index caf0f42..aa4a050 100644
--- a/src/main/java/com/android/tools/r8/synthesis/SyntheticItems.java
+++ b/src/main/java/com/android/tools/r8/synthesis/SyntheticItems.java
@@ -41,7 +41,6 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Consumer;
@@ -59,23 +58,17 @@
 
   /** Collection of pending items. */
   private static class PendingSynthetics {
-    /**
-     * Thread safe collection of synthesized classes that are not yet committed to the application.
-     *
-     * <p>TODO(b/158159959): Remove legacy support.
-     */
-    private final Map<DexType, LegacySyntheticDefinition> legacyClasses = new ConcurrentHashMap<>();
 
     /** Thread safe collection of synthetic items not yet committed to the application. */
     private final ConcurrentHashMap<DexType, SyntheticDefinition<?, ?, ?>> nonLegacyDefinitions =
         new ConcurrentHashMap<>();
 
     boolean isEmpty() {
-      return legacyClasses.isEmpty() && nonLegacyDefinitions.isEmpty();
+      return nonLegacyDefinitions.isEmpty();
     }
 
     boolean containsType(DexType type) {
-      return legacyClasses.containsKey(type) || nonLegacyDefinitions.containsKey(type);
+      return nonLegacyDefinitions.containsKey(type);
     }
 
     boolean containsTypeOfKind(DexType type, SyntheticKind kind) {
@@ -84,22 +77,17 @@
     }
 
     boolean verifyNotRewritten(NonIdentityGraphLens lens) {
-      assert legacyClasses.keySet().equals(lens.rewriteTypes(legacyClasses.keySet()));
       assert nonLegacyDefinitions.keySet().equals(lens.rewriteTypes(nonLegacyDefinitions.keySet()));
       return true;
     }
 
     Collection<DexProgramClass> getAllProgramClasses() {
-      List<DexProgramClass> allPending =
-          new ArrayList<>(nonLegacyDefinitions.size() + legacyClasses.size());
+      List<DexProgramClass> allPending = new ArrayList<>(nonLegacyDefinitions.size());
       for (SyntheticDefinition<?, ?, ?> item : nonLegacyDefinitions.values()) {
         if (item.isProgramDefinition()) {
           allPending.add(item.asProgramDefinition().getHolder());
         }
       }
-      for (LegacySyntheticDefinition legacy : legacyClasses.values()) {
-        allPending.add(legacy.getDefinition());
-      }
       return Collections.unmodifiableList(allPending);
     }
   }
@@ -189,22 +177,16 @@
   public DexClass definitionFor(DexType type, Function<DexType, DexClass> baseDefinitionFor) {
     DexClass clazz = null;
     SyntheticKind kind = null;
-    LegacySyntheticDefinition legacyItem = pending.legacyClasses.get(type);
-    if (legacyItem != null) {
-      clazz = legacyItem.getDefinition();
-    } else {
-      SyntheticDefinition<?, ?, ?> item = pending.nonLegacyDefinitions.get(type);
-      if (item != null) {
-        clazz = item.getHolder();
-        kind = item.getKind();
-        assert clazz.isProgramClass() == item.isProgramDefinition();
-        assert clazz.isClasspathClass() == item.isClasspathDefinition();
-      }
+    SyntheticDefinition<?, ?, ?> item = pending.nonLegacyDefinitions.get(type);
+    if (item != null) {
+      clazz = item.getHolder();
+      kind = item.getKind();
+      assert clazz.isProgramClass() == item.isProgramDefinition();
+      assert clazz.isClasspathClass() == item.isClasspathDefinition();
     }
     if (clazz != null) {
-      assert legacyItem != null || kind != null;
-      assert baseDefinitionFor.apply(type) == null
-              || (kind != null && kind.mayOverridesNonProgramType)
+      assert kind != null;
+      assert baseDefinitionFor.apply(type) == null || kind.mayOverridesNonProgramType
           : "Pending synthetic definition also present in the active program: " + type;
       return clazz;
     }
@@ -227,10 +209,6 @@
     return committed.containsType(type);
   }
 
-  private boolean isLegacyCommittedSynthetic(DexType type) {
-    return committed.containsLegacyType(type);
-  }
-
   private boolean isNonLegacyCommittedSynthetic(DexType type) {
     return committed.containsNonLegacyType(type);
   }
@@ -239,22 +217,10 @@
     return pending.containsType(type);
   }
 
-  private boolean isLegacyPendingSynthetic(DexType type) {
-    return pending.legacyClasses.containsKey(type);
-  }
-
   private boolean isNonLegacyPendingSynthetic(DexType type) {
     return pending.nonLegacyDefinitions.containsKey(type);
   }
 
-  public boolean isLegacySyntheticClass(DexType type) {
-    return isLegacyCommittedSynthetic(type) || isLegacyPendingSynthetic(type);
-  }
-
-  public boolean isLegacySyntheticClass(DexProgramClass clazz) {
-    return isLegacySyntheticClass(clazz.getType());
-  }
-
   public boolean isNonLegacySynthetic(DexProgramClass clazz) {
     return isNonLegacySynthetic(clazz.type);
   }
@@ -291,7 +257,7 @@
   }
 
   public boolean isSyntheticClass(DexType type) {
-    return isLegacySyntheticClass(type) || isNonLegacySynthetic(type);
+    return isNonLegacySynthetic(type);
   }
 
   public boolean isSyntheticClass(DexProgramClass clazz) {
@@ -307,18 +273,6 @@
   }
 
   public FeatureSplit getContextualFeatureSplit(DexType type) {
-    if (pending.legacyClasses.containsKey(type)) {
-      LegacySyntheticDefinition definition = pending.legacyClasses.get(type);
-      return definition.getFeatureSplit();
-    }
-    if (committed.containsLegacyType(type)) {
-      List<LegacySyntheticReference> types = committed.getLegacyTypes(type);
-      if (types.isEmpty()) {
-        return null;
-      }
-      assert verifyAllHaveSameFeature(types, LegacySyntheticReference::getFeatureSplit);
-      return types.get(0).getFeatureSplit();
-    }
     if (isSyntheticOfKind(type, SyntheticKind.ENUM_UNBOXING_SHARED_UTILITY_CLASS)) {
       return FeatureSplit.BASE;
     }
@@ -358,13 +312,6 @@
     ImmutableList.Builder<DexType> builder = ImmutableList.builder();
     forEachSynthesizingContext(
         type, synthesizingContext -> builder.add(synthesizingContext.getSynthesizingContextType()));
-    for (LegacySyntheticReference legacyReference : committed.getLegacyTypes(type)) {
-      builder.addAll(legacyReference.getContexts());
-    }
-    LegacySyntheticDefinition legacyDefinition = pending.legacyClasses.get(type);
-    if (legacyDefinition != null) {
-      builder.addAll(legacyDefinition.getContexts());
-    }
     return builder.build();
   }
 
@@ -416,10 +363,6 @@
     return true;
   }
 
-  public Collection<DexProgramClass> getLegacyPendingClasses() {
-    return ListUtils.map(pending.legacyClasses.values(), LegacySyntheticDefinition::getDefinition);
-  }
-
   private SynthesizingContext getSynthesizingContext(
       ProgramDefinition context, AppView<?> appView) {
     return getSynthesizingContext(
@@ -451,29 +394,6 @@
 
   // Addition and creation of synthetic items.
 
-  public void addLegacySyntheticClassForLibraryDesugaring(DexProgramClass clazz) {
-    internalAddLegacySyntheticClass(clazz);
-    // No context information is added for library context.
-    // This is intended only to support desugared-library compilation.
-  }
-
-  // TODO(b/158159959): Remove the usage of this direct class addition.
-  public void addLegacySyntheticClass(
-      DexProgramClass clazz, ProgramDefinition context, FeatureSplit featureSplit) {
-    LegacySyntheticDefinition legacyItem = internalAddLegacySyntheticClass(clazz);
-    legacyItem.addContext(context, featureSplit);
-  }
-
-  private LegacySyntheticDefinition internalAddLegacySyntheticClass(DexProgramClass clazz) {
-    assert !isCommittedSynthetic(clazz.type);
-    assert !pending.nonLegacyDefinitions.containsKey(clazz.type);
-    LegacySyntheticDefinition legacyItem =
-        pending.legacyClasses.computeIfAbsent(
-            clazz.getType(), type -> new LegacySyntheticDefinition(clazz));
-    assert legacyItem.getDefinition() == clazz;
-    return legacyItem;
-  }
-
   private DexProgramClass internalEnsureDexProgramClass(
       SyntheticKind kind,
       Consumer<SyntheticProgramClassBuilder> classConsumer,
@@ -824,9 +744,6 @@
     DexApplication application = prunedItems.getPrunedApp();
     Set<DexType> removedClasses = prunedItems.getNoLongerSyntheticItems();
     CommittedSyntheticsCollection.Builder builder = committed.builder();
-    // Legacy synthetics must already have been committed to the app.
-    assert verifyClassesAreInApp(application, pending.legacyClasses.values());
-    builder.addLegacyClasses(pending.legacyClasses);
     // Compute the synthetic additions and add them to the application.
     ImmutableList<DexType> committedProgramTypes;
     DexApplication amendedApplication;
@@ -863,15 +780,6 @@
         committedProgramTypes);
   }
 
-  private static boolean verifyClassesAreInApp(
-      DexApplication app, Collection<LegacySyntheticDefinition> classes) {
-    for (LegacySyntheticDefinition item : classes) {
-      DexProgramClass clazz = item.getDefinition();
-      assert app.programDefinitionFor(clazz.type) != null : "Missing synthetic: " + clazz.type;
-    }
-    return true;
-  }
-
   public void writeAttributeIfIntermediateSyntheticClass(
       ClassWriter writer, DexProgramClass clazz, AppView<?> appView) {
     if (!appView.options().intermediate || !appView.options().isGeneratingClassFiles()) {