[Retrace] Always add sourceFile to class mappings

When composing we cannot distinguish between original file name and one
that can be computed by R8. We should therefore always emit file names.

Bug: b/241763080
Change-Id: Ie5a0613efc3a2ab461083ee233135305cdf0b9a5
diff --git a/src/main/java/com/android/tools/r8/graph/AppView.java b/src/main/java/com/android/tools/r8/graph/AppView.java
index 9c659f5..dc99fda 100644
--- a/src/main/java/com/android/tools/r8/graph/AppView.java
+++ b/src/main/java/com/android/tools/r8/graph/AppView.java
@@ -35,7 +35,6 @@
 import com.android.tools.r8.optimize.argumentpropagation.ArgumentPropagator;
 import com.android.tools.r8.optimize.interfaces.collection.OpenClosedInterfacesCollection;
 import com.android.tools.r8.profile.art.ArtProfileCollection;
-import com.android.tools.r8.retrace.internal.RetraceUtils;
 import com.android.tools.r8.shaking.AppInfoWithLiveness;
 import com.android.tools.r8.shaking.AssumeInfoCollection;
 import com.android.tools.r8.shaking.KeepClassInfo;
@@ -983,9 +982,7 @@
   }
 
   public void addPrunedClassSourceFile(DexType prunedType, String sourceFile) {
-    if (!RetraceUtils.hasPredictableSourceFileName(prunedType.toSourceString(), sourceFile)) {
-      sourceFileForPrunedTypes.put(prunedType, sourceFile);
-    }
+    sourceFileForPrunedTypes.put(prunedType, sourceFile);
   }
 
   public String getPrunedClassSourceFileInfo(DexType dexType) {
diff --git a/src/main/java/com/android/tools/r8/retrace/internal/RetraceUtils.java b/src/main/java/com/android/tools/r8/retrace/internal/RetraceUtils.java
index 7c884e2..0180960 100644
--- a/src/main/java/com/android/tools/r8/retrace/internal/RetraceUtils.java
+++ b/src/main/java/com/android/tools/r8/retrace/internal/RetraceUtils.java
@@ -56,11 +56,6 @@
     return sb.toString();
   }
 
-  public static boolean hasPredictableSourceFileName(String originalClassName, String sourceFile) {
-    String synthesizedSourceFileName = getOuterClassSimpleName(originalClassName) + ".java";
-    return synthesizedSourceFileName.equals(sourceFile);
-  }
-
   private static String getOuterClassSimpleName(String clazz) {
     int lastIndexOfPeriod = clazz.lastIndexOf(DescriptorUtils.JAVA_PACKAGE_SEPARATOR);
     // Check if we can find a subclass separator.
diff --git a/src/main/java/com/android/tools/r8/utils/positions/MappedPositionToClassNameMapperBuilder.java b/src/main/java/com/android/tools/r8/utils/positions/MappedPositionToClassNameMapperBuilder.java
index 5603770..2b51ed8 100644
--- a/src/main/java/com/android/tools/r8/utils/positions/MappedPositionToClassNameMapperBuilder.java
+++ b/src/main/java/com/android/tools/r8/utils/positions/MappedPositionToClassNameMapperBuilder.java
@@ -41,7 +41,6 @@
 import com.android.tools.r8.naming.mappinginformation.RewriteFrameMappingInformation.ThrowsCondition;
 import com.android.tools.r8.references.MethodReference;
 import com.android.tools.r8.references.Reference;
-import com.android.tools.r8.retrace.internal.RetraceUtils;
 import com.android.tools.r8.synthesis.SyntheticItems;
 import com.android.tools.r8.utils.DescriptorUtils;
 import com.android.tools.r8.utils.InternalOptions.LineNumberOptimization;
@@ -108,7 +107,6 @@
           assert appView.appInfo().definitionForWithoutExistenceAssert(holder) == null;
           String typeName = holder.toSourceString();
           String sourceFile = entry.getValue();
-          assert !RetraceUtils.hasPredictableSourceFileName(typeName, sourceFile);
           classNameMapperBuilder
               .classNamingBuilder(
                   typeName, typeName, com.android.tools.r8.position.Position.UNKNOWN)
@@ -150,11 +148,9 @@
       // Check if source file should be added to the map
       DexString originalSourceFile = originalSourceFiles.getOriginalSourceFile(clazz);
       if (originalSourceFile != null) {
-        String sourceFile = originalSourceFile.toString();
-        if (!RetraceUtils.hasPredictableSourceFileName(clazz.toSourceString(), sourceFile)) {
-          getBuilder()
-              .addMappingInformation(FileNameInformation.build(sourceFile), Unreachable::raise);
-        }
+        getBuilder()
+            .addMappingInformation(
+                FileNameInformation.build(originalSourceFile.toSourceString()), Unreachable::raise);
       }
       return this;
     }