equal
deleted
inserted
replaced
1005 |
1005 |
1006 if (t.isCompound() && s.isCompound()) { |
1006 if (t.isCompound() && s.isCompound()) { |
1007 if (!visit(supertype(t), supertype(s))) |
1007 if (!visit(supertype(t), supertype(s))) |
1008 return false; |
1008 return false; |
1009 |
1009 |
1010 HashSet<SingletonType> set = new HashSet<SingletonType>(); |
1010 HashSet<UniqueType> set = new HashSet<UniqueType>(); |
1011 for (Type x : interfaces(t)) |
1011 for (Type x : interfaces(t)) |
1012 set.add(new SingletonType(x)); |
1012 set.add(new UniqueType(x, Types.this)); |
1013 for (Type x : interfaces(s)) { |
1013 for (Type x : interfaces(s)) { |
1014 if (!set.remove(new SingletonType(x))) |
1014 if (!set.remove(new UniqueType(x, Types.this))) |
1015 return false; |
1015 return false; |
1016 } |
1016 } |
1017 return (set.isEmpty()); |
1017 return (set.isEmpty()); |
1018 } |
1018 } |
1019 return t.tsym == s.tsym |
1019 return t.tsym == s.tsym |
3135 this.t1 = t1; |
3135 this.t1 = t1; |
3136 this.t2 = t2; |
3136 this.t2 = t2; |
3137 } |
3137 } |
3138 @Override |
3138 @Override |
3139 public int hashCode() { |
3139 public int hashCode() { |
3140 return 127 * Types.hashCode(t1) + Types.hashCode(t2); |
3140 return 127 * Types.this.hashCode(t1) + Types.this.hashCode(t2); |
3141 } |
3141 } |
3142 @Override |
3142 @Override |
3143 public boolean equals(Object obj) { |
3143 public boolean equals(Object obj) { |
3144 if (!(obj instanceof TypePair)) |
3144 if (!(obj instanceof TypePair)) |
3145 return false; |
3145 return false; |
3398 |
3398 |
3399 // <editor-fold defaultstate="collapsed" desc="hashCode"> |
3399 // <editor-fold defaultstate="collapsed" desc="hashCode"> |
3400 /** |
3400 /** |
3401 * Compute a hash code on a type. |
3401 * Compute a hash code on a type. |
3402 */ |
3402 */ |
3403 public static int hashCode(Type t) { |
3403 public int hashCode(Type t) { |
3404 return hashCode.visit(t); |
3404 return hashCode.visit(t); |
3405 } |
3405 } |
3406 // where |
3406 // where |
3407 private static final UnaryVisitor<Integer> hashCode = new UnaryVisitor<Integer>() { |
3407 private static final UnaryVisitor<Integer> hashCode = new UnaryVisitor<Integer>() { |
3408 |
3408 |
3418 for (Type s : t.getTypeArguments()) { |
3418 for (Type s : t.getTypeArguments()) { |
3419 result *= 127; |
3419 result *= 127; |
3420 result += visit(s); |
3420 result += visit(s); |
3421 } |
3421 } |
3422 return result; |
3422 return result; |
|
3423 } |
|
3424 |
|
3425 @Override |
|
3426 public Integer visitMethodType(MethodType t, Void ignored) { |
|
3427 int h = METHOD.ordinal(); |
|
3428 for (List<Type> thisargs = t.argtypes; |
|
3429 thisargs.tail != null; |
|
3430 thisargs = thisargs.tail) |
|
3431 h = (h << 5) + visit(thisargs.head); |
|
3432 return (h << 5) + visit(t.restype); |
3423 } |
3433 } |
3424 |
3434 |
3425 @Override |
3435 @Override |
3426 public Integer visitWildcardType(WildcardType t, Void ignored) { |
3436 public Integer visitWildcardType(WildcardType t, Void ignored) { |
3427 int result = t.kind.hashCode(); |
3437 int result = t.kind.hashCode(); |
4080 } |
4090 } |
4081 |
4091 |
4082 /** |
4092 /** |
4083 * A wrapper for a type that allows use in sets. |
4093 * A wrapper for a type that allows use in sets. |
4084 */ |
4094 */ |
4085 class SingletonType { |
4095 public static class UniqueType { |
4086 final Type t; |
4096 public final Type type; |
4087 SingletonType(Type t) { |
4097 final Types types; |
4088 this.t = t; |
4098 |
4089 } |
4099 public UniqueType(Type type, Types types) { |
|
4100 this.type = type; |
|
4101 this.types = types; |
|
4102 } |
|
4103 |
4090 public int hashCode() { |
4104 public int hashCode() { |
4091 return Types.hashCode(t); |
4105 return types.hashCode(type); |
4092 } |
4106 } |
|
4107 |
4093 public boolean equals(Object obj) { |
4108 public boolean equals(Object obj) { |
4094 return (obj instanceof SingletonType) && |
4109 return (obj instanceof UniqueType) && |
4095 isSameType(t, ((SingletonType)obj).t); |
4110 types.isSameType(type, ((UniqueType)obj).type); |
4096 } |
4111 } |
|
4112 |
4097 public String toString() { |
4113 public String toString() { |
4098 return t.toString(); |
4114 return type.toString(); |
4099 } |
4115 } |
|
4116 |
4100 } |
4117 } |
4101 // </editor-fold> |
4118 // </editor-fold> |
4102 |
4119 |
4103 // <editor-fold defaultstate="collapsed" desc="Visitors"> |
4120 // <editor-fold defaultstate="collapsed" desc="Visitors"> |
4104 /** |
4121 /** |