You need to sign in or sign up before continuing.
提交 ebe3c219 编写于 作者: V vromero

8138914: javac, method visitTypeVar() at visitor Types.hashCode generates the...

8138914: javac, method visitTypeVar() at visitor Types.hashCode generates the same hash code for different type variables
Reviewed-by: mcimadamore
上级 b64c5884
......@@ -3781,11 +3781,24 @@ public class Types {
* Compute a hash code on a type.
*/
public int hashCode(Type t) {
return hashCode.visit(t);
return hashCode(t, false);
}
public int hashCode(Type t, boolean strict) {
return strict ?
hashCodeStrictVisitor.visit(t) :
hashCodeVisitor.visit(t);
}
// where
private static final UnaryVisitor<Integer> hashCode = new UnaryVisitor<Integer>() {
private static final HashCodeVisitor hashCodeVisitor = new HashCodeVisitor();
private static final HashCodeVisitor hashCodeStrictVisitor = new HashCodeVisitor() {
@Override
public Integer visitTypeVar(TypeVar t, Void ignored) {
return System.identityHashCode(t);
}
};
private static class HashCodeVisitor extends UnaryVisitor<Integer> {
public Integer visitType(Type t, Void ignored) {
return t.getTag().ordinal();
}
......@@ -3841,7 +3854,7 @@ public class Types {
public Integer visitErrorType(ErrorType t, Void ignored) {
return 0;
}
};
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Return-Type-Substitutable">
......
......@@ -1254,9 +1254,9 @@ public class Infer {
public int hashCode() {
int result = opKind.hashCode();
result *= 127;
result += types.hashCode(op1);
result += types.hashCode(op1, true);
result *= 127;
result += types.hashCode(op2);
result += types.hashCode(op2, true);
return result;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册