Add equals/hashCode/toString for JVM signatures
This commit is contained in:
+21
-4
@@ -19,13 +19,11 @@ package org.jetbrains.jet.codegen.signature;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
|
||||
public class JvmMethodParameterSignature {
|
||||
@NotNull
|
||||
public final class JvmMethodParameterSignature {
|
||||
private final Type asmType;
|
||||
@NotNull
|
||||
private final JvmMethodParameterKind kind;
|
||||
|
||||
public JvmMethodParameterSignature(@NotNull Type asmType, @NotNull JvmMethodParameterKind kind) {
|
||||
JvmMethodParameterSignature(@NotNull Type asmType, @NotNull JvmMethodParameterKind kind) {
|
||||
this.asmType = asmType;
|
||||
this.kind = kind;
|
||||
}
|
||||
@@ -39,4 +37,23 @@ public class JvmMethodParameterSignature {
|
||||
public JvmMethodParameterKind getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof JvmMethodParameterSignature)) return false;
|
||||
|
||||
JvmMethodParameterSignature that = (JvmMethodParameterSignature) o;
|
||||
return asmType.equals(that.asmType) && kind == that.kind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * asmType.hashCode() + kind.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return kind + " " + asmType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class JvmMethodSignature {
|
||||
private final String genericsSignature;
|
||||
private final List<JvmMethodParameterSignature> valueParameters;
|
||||
|
||||
protected JvmMethodSignature(
|
||||
JvmMethodSignature(
|
||||
@NotNull Method asmMethod,
|
||||
@Nullable String genericsSignature,
|
||||
@NotNull List<JvmMethodParameterSignature> valueParameters
|
||||
@@ -65,6 +65,26 @@ public class JvmMethodSignature {
|
||||
new JvmMethodSignature(new Method(newName, asmMethod.getDescriptor()), genericsSignature, valueParameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof JvmMethodSignature)) return false;
|
||||
|
||||
JvmMethodSignature that = (JvmMethodSignature) o;
|
||||
|
||||
return asmMethod.equals(that.asmMethod) &&
|
||||
(genericsSignature == null ? that.genericsSignature == null : genericsSignature.equals(that.genericsSignature)) &&
|
||||
valueParameters.equals(that.valueParameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = asmMethod.hashCode();
|
||||
result = 31 * result + (genericsSignature != null ? genericsSignature.hashCode() : 0);
|
||||
result = 31 * result + valueParameters.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asmMethod.toString();
|
||||
|
||||
Reference in New Issue
Block a user