Relax check in Enqueuer.ensureFromLibraryOrThrow to allow for classpath
Classpath classes are allowed to extend and use interfaces from
library and classpath files.
Change-Id: I5a0782cf3e0efef2b96075041e2009418c249bc6
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 c117087..b0c7777 100644
--- a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
+++ b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
@@ -839,9 +839,9 @@
markTypeAsLive(holder.superType);
if (holder.isNotProgramClass()) {
// Library classes may only extend other implement library classes.
- ensureFromLibraryOrThrow(holder.superType, type);
+ ensureNotFromProgramOrThrow(holder.superType, type);
for (DexType iface : holder.interfaces.values) {
- ensureFromLibraryOrThrow(iface, type);
+ ensureNotFromProgramOrThrow(iface, type);
}
}
}
@@ -948,7 +948,7 @@
}
}
- private void ensureFromLibraryOrThrow(DexType type, DexType context) {
+ private void ensureNotFromProgramOrThrow(DexType type, DexType context) {
if (tracingMainDex) {
// b/72312389: android.jar contains parts of JUnit and most developers include JUnit in
// their programs. This leads to library classes extending program classes. When tracing
@@ -956,14 +956,14 @@
return;
}
- DexClass holder = appView.definitionFor(type);
- if (holder != null && !holder.isLibraryClass()) {
+ DexClass clazz = appView.definitionFor(type);
+ if (clazz != null && clazz.isProgramClass()) {
if (!dontWarnPatterns.matches(context)) {
Diagnostic message =
new StringDiagnostic(
"Library class "
+ context.toSourceString()
- + (holder.isInterface() ? " implements " : " extends ")
+ + (clazz.isInterface() ? " implements " : " extends ")
+ "program class "
+ type.toSourceString());
if (tracingMainDex || forceProguardCompatibility) {