Only add keep rule when there is a default ctor

This CL only affects Proguard compat mode.

Prior to commits 63c52a2cb840c7afb220a2d1090e207cfea33236 and 11e6d3b792f1ff7d0ada3f0d2e01d3485cfe030e, a type mentioned in a const-class or check-cast instruction was only marked as being instantiated if it was a program class with a default initializer (others were merely marked as being live). These changes therefore lead to a small regression (c.f. referenced bug).

This CL goes back to only marking program classes with a default initializer as being instantiated, as we used to.

Bug: 74723594
Change-Id: I8a92857455f4c9e40deb5f059c73d360a4cdbe23
diff --git a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
index d718026..19fe18e 100644
--- a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
+++ b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
@@ -460,10 +460,11 @@
         DexType baseType = type.toBaseType(appInfo.dexItemFactory);
         if (baseType.isClassType()) {
           DexClass baseClass = appInfo.definitionFor(baseType);
-          if (baseClass != null && !baseClass.isLibraryClass()) {
+          if (baseClass != null && baseClass.isProgramClass()
+              && baseClass.hasDefaultInitializer()) {
             markClassAsInstantiatedWithCompatRule(baseClass);
           } else {
-            // This handles reporting of missing classes.
+            // This also handles reporting of missing classes.
             markTypeAsLive(baseType);
           }
           return true;