mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-15 18:33:41 +00:00
8138914: javac, method visitTypeVar() at visitor Types.hashCode generates the same hash code for different type variables
Reviewed-by: mcimadamore
This commit is contained in:
parent
a113b52db0
commit
38c2534531
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user