Do not report missing references from kotlin.Metadata
Change-Id: Iae8ca2e67f7308658f3cc77d8a8cc7c5edbe8724
diff --git a/src/main/java/com/android/tools/r8/tracereferences/UseCollector.java b/src/main/java/com/android/tools/r8/tracereferences/UseCollector.java
index 191dd0e..7fc2660 100644
--- a/src/main/java/com/android/tools/r8/tracereferences/UseCollector.java
+++ b/src/main/java/com/android/tools/r8/tracereferences/UseCollector.java
@@ -71,6 +71,7 @@
private final DexItemFactory factory;
private final TraceReferencesConsumer consumer;
private final DiagnosticsHandler diagnostics;
+ private final UseCollectorEventConsumer kotlinMetadataEventConsumer;
private final Predicate<DexType> targetPredicate;
private final Set<ClassReference> missingClasses = ConcurrentHashMap.newKeySet();
@@ -88,6 +89,7 @@
this.factory = appView.dexItemFactory();
this.consumer = consumer;
this.diagnostics = diagnostics;
+ this.kotlinMetadataEventConsumer = new KotlinMetadataUseCollectorEventConsumer(this);
this.targetPredicate = targetPredicate;
this.dalvikAnnotationCodegenPrefix = factory.createString("Ldalvik/annotation/codegen/");
}
@@ -117,7 +119,7 @@
for (DexAnnotation annotation : clazz.annotations().getAnnotations()) {
registerAnnotation(annotation, clazz, classContext, getDefaultEventConsumer());
}
- traceKotlinMetadata(clazz, classContext, getDefaultEventConsumer());
+ traceKotlinMetadata(clazz, classContext, kotlinMetadataEventConsumer);
traceSignature(clazz, classContext, getDefaultEventConsumer());
}
@@ -770,4 +772,55 @@
}
}
}
+
+ private static class KotlinMetadataUseCollectorEventConsumer
+ implements UseCollectorEventConsumer {
+
+ private final UseCollectorEventConsumer parent;
+
+ private KotlinMetadataUseCollectorEventConsumer(UseCollectorEventConsumer parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ public void notifyPresentClass(DexClass clazz, DefinitionContext referencedFrom) {
+ parent.notifyPresentClass(clazz, referencedFrom);
+ }
+
+ @Override
+ public void notifyMissingClass(DexType type, DefinitionContext referencedFrom) {
+ // Intentionally empty.
+ }
+
+ @Override
+ public void notifyPresentField(DexClassAndField field, DefinitionContext referencedFrom) {
+ parent.notifyPresentField(field, referencedFrom);
+ }
+
+ @Override
+ public void notifyMissingField(DexField field, DefinitionContext referencedFrom) {
+ // Intentionally empty.
+ }
+
+ @Override
+ public void notifyPresentMethod(DexClassAndMethod method, DefinitionContext referencedFrom) {
+ parent.notifyPresentMethod(method, referencedFrom);
+ }
+
+ @Override
+ public void notifyPresentMethod(
+ DexClassAndMethod method, DefinitionContext referencedFrom, DexMethod reference) {
+ parent.notifyPresentMethod(method, referencedFrom, reference);
+ }
+
+ @Override
+ public void notifyMissingMethod(DexMethod method, DefinitionContext referencedFrom) {
+ // Intentionally empty.
+ }
+
+ @Override
+ public void notifyPackageOf(Definition definition) {
+ parent.notifyPackageOf(definition);
+ }
+ }
}