Show receiver in debug info of desugared default method

When we desugar a default method (of an interface), we move its code
to a static method of a companion class. In order to access the
original receiver (instance of the interface), we pass it in the
arguments of the method.

For debugging, we must give it a name so that it can be seen by the
debugger. Though its natural name would be "this", we cannot use
that name because the debugger may hide it (due to the method being
static).

In order to workaround that issue, we choose the name "-this". Indeed
it starts by a character that should not appear in the source code.

Bug: 62290295
Change-Id: I5064701cb22f6b84bea02ce5efe11fcf296968a9
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/InterfaceProcessor.java b/src/main/java/com/android/tools/r8/ir/desugar/InterfaceProcessor.java
index 8c17d91..768d6a1 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/InterfaceProcessor.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/InterfaceProcessor.java
@@ -62,8 +62,10 @@
         newFlags.unsetBridge();
         newFlags.setStatic();
         DexCode dexCode = code.asDexCode();
-        // TODO(ager): Should we give the new first parameter an actual name? Maybe 'this'?
-        dexCode.setDebugInfo(dexCode.debugInfoWithAdditionalFirstParameter(null));
+        // We cannot name the parameter "this" because the debugger may omit it due to the method
+        // actually being static. Instead we prepend it with a special character.
+        dexCode.setDebugInfo(dexCode.debugInfoWithAdditionalFirstParameter(
+            rewriter.factory.createString("-this")));
         assert (dexCode.getDebugInfo() == null)
             || (companionMethod.getArity() == dexCode.getDebugInfo().parameters.length);
 
diff --git a/src/test/java/com/android/tools/r8/debug/InterfaceMethodTest.java b/src/test/java/com/android/tools/r8/debug/InterfaceMethodTest.java
index c5c21a7..26d3d5c 100644
--- a/src/test/java/com/android/tools/r8/debug/InterfaceMethodTest.java
+++ b/src/test/java/com/android/tools/r8/debug/InterfaceMethodTest.java
@@ -58,6 +58,8 @@
     // TODO(shertz) we should see the local variable this even when desugaring.
     if (supportsDefaultMethod(config)) {
       commands.add(checkLocal("this"));
+    } else {
+      commands.add(checkLocal("-this"));
     }
     commands.add(checkLocal(parameterName));
     commands.add(stepOver(INTELLIJ_FILTER));