Remove some warning suppressions and unused methods
Change-Id: I2ea8cf174dff16f3ad5c3b76e5103322689b785f
diff --git a/src/main/java/com/android/tools/r8/origin/Origin.java b/src/main/java/com/android/tools/r8/origin/Origin.java
index 3a8aa97..0f3d320 100644
--- a/src/main/java/com/android/tools/r8/origin/Origin.java
+++ b/src/main/java/com/android/tools/r8/origin/Origin.java
@@ -89,24 +89,6 @@
return parts;
}
- /**
- * Find first parent or this instance of the given class.
- * @return This {@link Origin} if it's an instance of the requested {@link Class} or the first
- * parent found matching the condition. May return null if no satisfying instance is found.
- */
- @SuppressWarnings("unchecked")
- public <T extends Origin> T getFromHierarchy(Class<T> type) {
- Origin origin = this;
- do {
- if (type.isInstance(origin)) {
- return (T) origin;
- }
- origin = origin.parent();
- } while (origin != null);
- return null;
- }
-
-
@Override
public boolean equals(Object obj) {
if (obj == this) {
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 539d36c..d07235f 100644
--- a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
+++ b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
@@ -689,17 +689,6 @@
return definitionFor(type, context, this::recordNonProgramClass, this::reportMissingClass);
}
- public DexLibraryClass definitionForLibraryClassOrIgnore(DexType type) {
- assert type.isClassType();
- ClassResolutionResult classResolutionResult =
- appInfo().contextIndependentDefinitionForWithResolutionResult(type);
- return classResolutionResult.hasClassResolutionResult()
- && !classResolutionResult.isMultipleClassResolutionResult()
- ? DexLibraryClass.asLibraryClassOrNull(
- classResolutionResult.toSingleClassWithProgramOverLibrary())
- : null;
- }
-
public boolean hasAlternativeLibraryDefinition(DexProgramClass programClass) {
ClassResolutionResult classResolutionResult =
internalDefinitionFor(
diff --git a/src/main/java/com/android/tools/r8/shaking/WhyAreYouKeepingConsumer.java b/src/main/java/com/android/tools/r8/shaking/WhyAreYouKeepingConsumer.java
index 0d7cb4a..a020011 100644
--- a/src/main/java/com/android/tools/r8/shaking/WhyAreYouKeepingConsumer.java
+++ b/src/main/java/com/android/tools/r8/shaking/WhyAreYouKeepingConsumer.java
@@ -58,30 +58,28 @@
super(subConsumer);
}
- @SuppressWarnings("ReferenceEquality")
public ClassGraphNode getClassNode(ClassReference clazz) {
for (GraphNode node : getTargets()) {
- if (node instanceof ClassGraphNode && ((ClassGraphNode) node).getReference() == clazz) {
+ if (node instanceof ClassGraphNode && ((ClassGraphNode) node).getReference().equals(clazz)) {
return (ClassGraphNode) node;
}
}
return null;
}
- @SuppressWarnings("ReferenceEquality")
public MethodGraphNode getMethodNode(MethodReference method) {
for (GraphNode node : getTargets()) {
- if (node instanceof MethodGraphNode && ((MethodGraphNode) node).getReference() == method) {
+ if (node instanceof MethodGraphNode
+ && ((MethodGraphNode) node).getReference().equals(method)) {
return (MethodGraphNode) node;
}
}
return null;
}
- @SuppressWarnings("ReferenceEquality")
public FieldGraphNode getFieldNode(FieldReference field) {
for (GraphNode node : getTargets()) {
- if (node instanceof FieldGraphNode && ((FieldGraphNode) node).getReference() == field) {
+ if (node instanceof FieldGraphNode && ((FieldGraphNode) node).getReference().equals(field)) {
return (FieldGraphNode) node;
}
}
@@ -196,7 +194,6 @@
addNodeMessage(node, formatter);
}
- @SuppressWarnings("ReferenceEquality")
private String getNodeString(GraphNode node) {
if (node instanceof ClassGraphNode) {
return DescriptorUtils.descriptorToJavaType(
@@ -224,7 +221,7 @@
}
if (node instanceof KeepRuleGraphNode) {
KeepRuleGraphNode keepRuleNode = (KeepRuleGraphNode) node;
- return keepRuleNode.getOrigin() == Origin.unknown()
+ return Origin.unknown().equals(keepRuleNode.getOrigin())
? keepRuleNode.getContent()
: keepRuleNode.getOrigin() + ":" + shortPositionInfo(keepRuleNode.getPosition());
}