Skip to content

Commit 07f3f73

Browse files
committed
Drop TypeHashSet
Use a normal util.HashSet instead
1 parent 5301a8a commit 07f3f73

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5532,15 +5532,11 @@ object Types {
55325532
def apply(x: Unit, tp: Type): Unit = foldOver(p(tp), tp)
55335533
}
55345534

5535-
class TypeHashSet extends util.HashSet[Type](64):
5536-
override def hash(x: Type): Int = System.identityHashCode(x)
5537-
override def isEqual(x: Type, y: Type) = x.eq(y)
5538-
55395535
class NamedPartsAccumulator(p: NamedType => Boolean, excludeLowerBounds: Boolean = false)
55405536
(using Context) extends TypeAccumulator[mutable.Set[NamedType]] {
55415537
override def stopAtStatic: Boolean = false
55425538
def maybeAdd(x: mutable.Set[NamedType], tp: NamedType): mutable.Set[NamedType] = if (p(tp)) x += tp else x
5543-
val seen = TypeHashSet()
5539+
val seen = util.HashSet[Type]()
55445540
def apply(x: mutable.Set[NamedType], tp: Type): mutable.Set[NamedType] =
55455541
if (seen contains tp) x
55465542
else {

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import Trees._
2828
import transform.SymUtils._
2929
import transform.TypeUtils._
3030
import Hashable._
31-
import util.{SourceFile, NoSource}
31+
import util.{SourceFile, NoSource, IdentityHashMap}
3232
import config.{Config, Feature}
3333
import Feature.migrateTo3
3434
import config.Printers.{implicits, implicitsDetailed}
@@ -289,7 +289,7 @@ object Implicits:
289289
* @param outerCtx the next outer context that makes visible further implicits
290290
*/
291291
class ContextualImplicits(val refs: List[ImplicitRef], val outerImplicits: ContextualImplicits)(initctx: Context) extends ImplicitRefs(initctx) {
292-
private val eligibleCache = new java.util.IdentityHashMap[Type, List[Candidate]]
292+
private val eligibleCache = IdentityHashMap[Type, List[Candidate]]()
293293

294294
/** The level increases if current context has a different owner or scope than
295295
* the context of the next-outer ImplicitRefs. This is however disabled under
@@ -316,7 +316,7 @@ object Implicits:
316316
def eligible(tp: Type): List[Candidate] =
317317
if (tp.hash == NotCached) computeEligible(tp)
318318
else {
319-
val eligibles = eligibleCache.get(tp)
319+
val eligibles = eligibleCache.lookup(tp)
320320
if (eligibles != null) {
321321
def elided(ci: ContextualImplicits): Int = {
322322
val n = ci.refs.length
@@ -329,7 +329,7 @@ object Implicits:
329329
else if (irefCtx eq NoContext) Nil
330330
else {
331331
val result = computeEligible(tp)
332-
eligibleCache.put(tp, result)
332+
eligibleCache(tp) = result
333333
result
334334
}
335335
}
@@ -528,7 +528,7 @@ trait ImplicitRunInfo:
528528

529529
private var provisional: Boolean = _
530530
private var parts: mutable.LinkedHashSet[Type] = _
531-
private val partSeen = TypeHashSet()
531+
private val partSeen = util.HashSet[Type]()
532532

533533
def traverse(t: Type) =
534534
if partSeen.contains(t) then ()
@@ -566,8 +566,8 @@ trait ImplicitRunInfo:
566566
(parts, provisional)
567567
end collectParts
568568

569-
val seen = TypeHashSet()
570-
val incomplete = TypeHashSet()
569+
val seen = util.HashSet[Type]()
570+
val incomplete = util.HashSet[Type]()
571571

572572
def collectCompanions(tp: Type, parts: collection.Set[Type]): TermRefSet =
573573
val companions = new TermRefSet
@@ -687,7 +687,7 @@ trait ImplicitRunInfo:
687687
record(i"implicitScope")
688688
val liftToAnchors = new TypeMap:
689689
override def stopAtStatic = true
690-
private val seen = TypeHashSet()
690+
private val seen = util.HashSet[Type]()
691691

692692
def applyToUnderlying(t: TypeProxy) =
693693
if seen.contains(t) then

0 commit comments

Comments
 (0)