Introduce DexMethodSignature to replace Wrapper<DexMethod>
Change-Id: Id81069ed4a293ebf7530715fba0b0291c6417710
diff --git a/src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java b/src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java
index c92307e..b9993c7 100644
--- a/src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java
+++ b/src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java
@@ -381,6 +381,10 @@
return method;
}
+ public DexMethodSignature getSignature() {
+ return new DexMethodSignature(method);
+ }
+
public DexTypeList parameters() {
return method.proto.parameters;
}
diff --git a/src/main/java/com/android/tools/r8/graph/DexMethod.java b/src/main/java/com/android/tools/r8/graph/DexMethod.java
index 74b0fff..6c288c7 100644
--- a/src/main/java/com/android/tools/r8/graph/DexMethod.java
+++ b/src/main/java/com/android/tools/r8/graph/DexMethod.java
@@ -110,6 +110,10 @@
return proto.parameters.size();
}
+ public DexMethodSignature getSignature() {
+ return new DexMethodSignature(this);
+ }
+
@Override
public void collectIndexedItems(IndexedItemCollection indexedItems) {
if (collectIndexedItemsExceptName(indexedItems)) {
diff --git a/src/main/java/com/android/tools/r8/graph/DexMethodSignature.java b/src/main/java/com/android/tools/r8/graph/DexMethodSignature.java
new file mode 100644
index 0000000..4c736cb
--- /dev/null
+++ b/src/main/java/com/android/tools/r8/graph/DexMethodSignature.java
@@ -0,0 +1,48 @@
+// Copyright (c) 2020, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.graph;
+
+import java.util.Objects;
+
+public class DexMethodSignature {
+ private final DexProto proto;
+ private final DexString name;
+
+ public DexMethodSignature(DexMethod method) {
+ this(method.proto, method.name);
+ }
+
+ public DexMethodSignature(DexProto proto, DexString name) {
+ assert proto != null;
+ assert name != null;
+ this.proto = proto;
+ this.name = name;
+ }
+
+ public DexProto getProto() {
+ return proto;
+ }
+
+ public DexString getName() {
+ return name;
+ }
+
+ public DexMethod withHolder(DexType holder, DexItemFactory dexItemFactory) {
+ return dexItemFactory.createMethod(holder, proto, name);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ DexMethodSignature that = (DexMethodSignature) o;
+ return proto == proto && name == name;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(proto, name);
+ }
+}