@@ -4966,22 +4966,19 @@ object Types {
4966
4966
}
4967
4967
4968
4968
class TypeSizeAccumulator (implicit ctx : Context ) extends TypeAccumulator [Int ] {
4969
- val seen : util.HashSet [Type ] = new util.HashSet [Type ](64 ) {
4970
- override def hash (x : Type ): Int = System .identityHashCode(x)
4971
- override def isEqual (x : Type , y : Type ) = x.eq(y)
4972
- }
4969
+ val seen = new java.util.IdentityHashMap [Type , Type ]
4973
4970
def apply (n : Int , tp : Type ): Int =
4974
- if (seen contains tp ) n
4971
+ if (seen.get(tp) != null ) n
4975
4972
else {
4976
- seen.addEntry( tp)
4973
+ seen.put(tp, tp)
4977
4974
tp match {
4978
4975
case tp : AppliedType =>
4979
4976
foldOver(n + 1 , tp)
4980
4977
case tp : RefinedType =>
4981
4978
foldOver(n + 1 , tp)
4982
4979
case tp : TypeRef if tp.info.isTypeAlias =>
4983
4980
apply(n, tp.superType)
4984
- case tp : TypeParamRef if ! seen(tp) =>
4981
+ case tp : TypeParamRef =>
4985
4982
apply(n, ctx.typeComparer.bounds(tp))
4986
4983
case _ =>
4987
4984
foldOver(n, tp)
@@ -4990,14 +4987,11 @@ object Types {
4990
4987
}
4991
4988
4992
4989
class CoveringSetAccumulator (implicit ctx : Context ) extends TypeAccumulator [Set [Symbol ]] {
4993
- val seen : util.HashSet [Type ] = new util.HashSet [Type ](64 ) {
4994
- override def hash (x : Type ): Int = System .identityHashCode(x)
4995
- override def isEqual (x : Type , y : Type ) = x.eq(y)
4996
- }
4990
+ val seen = new java.util.IdentityHashMap [Type , Type ]
4997
4991
def apply (cs : Set [Symbol ], tp : Type ): Set [Symbol ] = {
4998
- if (seen contains tp ) cs
4992
+ if (seen.get(tp) != null ) cs
4999
4993
else {
5000
- seen.addEntry( tp)
4994
+ seen.put(tp, tp)
5001
4995
tp match {
5002
4996
case tp if tp.isTopType || tp.isBottomType =>
5003
4997
cs
0 commit comments