Skip to content

Commit 8d0109a

Browse files
committed
Rename SimpleMap -> SimpleIdenitityMap
1 parent 0baf589 commit 8d0109a

File tree

8 files changed

+37
-37
lines changed

8 files changed

+37
-37
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Comments._
1717
import util.Positions._
1818
import ast.Trees._
1919
import ast.untpd
20-
import util.{FreshNameCreator, SimpleMap, SourceFile, NoSource}
20+
import util.{FreshNameCreator, SimpleIdentityMap, SourceFile, NoSource}
2121
import typer.{Implicits, ImplicitRunInfo, ImportInfo, Inliner, NamerContextOps, SearchHistory, TypeAssigner, Typer}
2222
import Implicits.ContextualImplicits
2323
import config.Settings._
@@ -694,14 +694,14 @@ object Contexts {
694694
implicit val ctx: Context = initctx
695695
}
696696

697-
class GADTMap(initBounds: SimpleMap[Symbol, TypeBounds]) extends util.DotClass {
697+
class GADTMap(initBounds: SimpleIdentityMap[Symbol, TypeBounds]) extends util.DotClass {
698698
private var myBounds = initBounds
699699
def setBounds(sym: Symbol, b: TypeBounds): Unit =
700700
myBounds = myBounds.updated(sym, b)
701701
def bounds = myBounds
702702
}
703703

704-
@sharable object EmptyGADTMap extends GADTMap(SimpleMap.Empty) {
704+
@sharable object EmptyGADTMap extends GADTMap(SimpleIdentityMap.Empty) {
705705
override def setBounds(sym: Symbol, b: TypeBounds) = unsupported("EmptyGADTMap.setBounds")
706706
}
707707
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotc
33
package core
44

55
import Types._, Contexts._, Symbols._, Decorators._
6-
import util.SimpleMap
6+
import util.SimpleIdentityMap
77
import collection.mutable
88
import printing.{Printer, Showable}
99
import printing.Texts._
@@ -14,7 +14,7 @@ import annotation.tailrec
1414

1515
object OrderingConstraint {
1616

17-
type ArrayValuedMap[T] = SimpleMap[TypeLambda, Array[T]]
17+
type ArrayValuedMap[T] = SimpleIdentityMap[TypeLambda, Array[T]]
1818

1919
/** The type of `OrderingConstraint#boundsMap` */
2020
type ParamBounds = ArrayValuedMap[Type]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Decorators.SymbolIteratorDecorator
1313
import ast._
1414
import annotation.tailrec
1515
import CheckRealizable._
16-
import util.SimpleMap
16+
import util.SimpleIdentityMap
1717
import util.Stats
1818
import java.util.WeakHashMap
1919
import config.Config
@@ -1254,7 +1254,7 @@ object SymDenotations {
12541254
// ----- caches -------------------------------------------------------
12551255

12561256
private[this] var myTypeParams: List[TypeSymbol] = null
1257-
private[this] var fullNameCache: SimpleMap[QualifiedNameKind, Name] = SimpleMap.Empty
1257+
private[this] var fullNameCache: SimpleIdentityMap[QualifiedNameKind, Name] = SimpleIdentityMap.Empty
12581258

12591259
private[this] var myMemberCache: LRUCache[Name, PreDenotation] = null
12601260
private[this] var myMemberCachePeriod: Period = Nowhere
@@ -2041,7 +2041,7 @@ object SymDenotations {
20412041
}
20422042

20432043
private class MemberNamesImpl(createdAt: Period) extends InheritedCacheImpl(createdAt) with MemberNames {
2044-
private[this] var cache: SimpleMap[NameFilter, Set[Name]] = SimpleMap.Empty
2044+
private[this] var cache: SimpleIdentityMap[NameFilter, Set[Name]] = SimpleIdentityMap.Empty
20452045

20462046
final def isValid(implicit ctx: Context): Boolean =
20472047
cache != null && isValidAt(ctx.phase)
@@ -2054,7 +2054,7 @@ object SymDenotations {
20542054
*/
20552055
def invalidate(): Unit =
20562056
if (cache != null)
2057-
if (locked) cache = SimpleMap.Empty
2057+
if (locked) cache = SimpleIdentityMap.Empty
20582058
else {
20592059
cache = null
20602060
invalidateDependents()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package core
55
import Types._
66
import Flags._
77
import Contexts._
8-
import util.{SimpleMap, DotClass}
8+
import util.{SimpleIdentityMap, DotClass}
99
import reporting._
1010
import printing.{Showable, Printer}
1111
import printing.Texts._
@@ -24,7 +24,7 @@ class TyperState(previous: TyperState /* | Null */) extends DotClass with Showab
2424
def setReporter(reporter: Reporter): this.type = { myReporter = reporter; this }
2525

2626
private var myConstraint: Constraint =
27-
if (previous == null) new OrderingConstraint(SimpleMap.Empty, SimpleMap.Empty, SimpleMap.Empty)
27+
if (previous == null) new OrderingConstraint(SimpleIdentityMap.Empty, SimpleIdentityMap.Empty, SimpleIdentityMap.Empty)
2828
else previous.constraint
2929

3030
def constraint = myConstraint

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import ast.{tpd, untpd}
66
import ast.Trees._
77
import core._
88
import printing.{Printer, Showable}
9-
import util.SimpleMap
9+
import util.SimpleIdentityMap
1010
import Symbols._, Names._, Denotations._, Types._, Contexts._, StdNames._, Flags._
1111
import Decorators.StringInterpolators
1212

@@ -52,7 +52,7 @@ class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree],
5252
def excluded: Set[TermName] = { ensureInitialized(); myExcluded }
5353

5454
/** A mapping from renamed to original names */
55-
def reverseMapping: SimpleMap[TermName, TermName] = { ensureInitialized(); myMapped }
55+
def reverseMapping: SimpleIdentityMap[TermName, TermName] = { ensureInitialized(); myMapped }
5656

5757
/** The original names imported by-name before renaming */
5858
def originals: Set[TermName] = { ensureInitialized(); myOriginals }
@@ -61,14 +61,14 @@ class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree],
6161
def isWildcardImport = { ensureInitialized(); myWildcardImport }
6262

6363
private var myExcluded: Set[TermName] = null
64-
private var myMapped: SimpleMap[TermName, TermName] = null
64+
private var myMapped: SimpleIdentityMap[TermName, TermName] = null
6565
private var myOriginals: Set[TermName] = null
6666
private var myWildcardImport: Boolean = false
6767

6868
/** Compute info relating to the selector list */
6969
private def ensureInitialized(): Unit = if (myExcluded == null) {
7070
myExcluded = Set()
71-
myMapped = SimpleMap.Empty
71+
myMapped = SimpleIdentityMap.Empty
7272
myOriginals = Set()
7373
def recur(sels: List[untpd.Tree]): Unit = sels match {
7474
case sel :: sels1 =>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Scopes._
1111
import ProtoTypes._
1212
import annotation.unchecked
1313
import util.Positions._
14-
import util.{Stats, SimpleMap}
14+
import util.{Stats, SimpleIdentityMap}
1515
import util.common._
1616
import Decorators._
1717
import Uniques._
@@ -286,7 +286,7 @@ object Inferencing {
286286
result
287287
}
288288

289-
type VarianceMap = SimpleMap[TypeVar, Integer]
289+
type VarianceMap = SimpleIdentityMap[TypeVar, Integer]
290290

291291
/** All occurrences of type vars in this type that satisfy predicate
292292
* `include` mapped to their variances (-1/0/1) in this type, where
@@ -350,7 +350,7 @@ object Inferencing {
350350
if (vmap1 eq vmap) vmap else propagate(vmap1)
351351
}
352352

353-
propagate(accu(SimpleMap.Empty, tp))
353+
propagate(accu(SimpleIdentityMap.Empty, tp))
354354
}
355355
}
356356

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Constants._
1111
import Scopes._
1212
import annotation.unchecked
1313
import util.Positions._
14-
import util.{Stats, SimpleMap}
14+
import util.{Stats, SimpleIdentityMap}
1515
import util.common._
1616
import Decorators._
1717
import Uniques._
@@ -179,10 +179,10 @@ object ProtoTypes {
179179
override def resultType(implicit ctx: Context) = resType
180180

181181
/** A map in which typed arguments can be stored to be later integrated in `typedArgs`. */
182-
private var myTypedArg: SimpleMap[untpd.Tree, Tree] = SimpleMap.Empty
182+
private var myTypedArg: SimpleIdentityMap[untpd.Tree, Tree] = SimpleIdentityMap.Empty
183183

184184
/** A map recording the typer states in which arguments stored in myTypedArg were typed */
185-
private var evalState: SimpleMap[untpd.Tree, TyperState] = SimpleMap.Empty
185+
private var evalState: SimpleIdentityMap[untpd.Tree, TyperState] = SimpleIdentityMap.Empty
186186

187187
def isMatchedBy(tp: Type)(implicit ctx: Context) =
188188
typer.isApplicable(tp, Nil, typedArgs, resultType)

compiler/src/dotty/tools/dotc/util/SimpleMap.scala

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package dotty.tools.dotc.util
22

33
import collection.mutable.ListBuffer
44

5-
abstract class SimpleMap[K <: AnyRef, +V >: Null <: AnyRef] extends (K => V) {
5+
abstract class SimpleIdentityMap[K <: AnyRef, +V >: Null <: AnyRef] extends (K => V) {
66
def size: Int
77
def apply(k: K): V
8-
def remove(k: K): SimpleMap[K, V]
9-
def updated[V1 >: V <: AnyRef](k: K, v: V1): SimpleMap[K, V1]
8+
def remove(k: K): SimpleIdentityMap[K, V]
9+
def updated[V1 >: V <: AnyRef](k: K, v: V1): SimpleIdentityMap[K, V1]
1010
def contains(k: K): Boolean = apply(k) != null
11-
def mapValuesNow[V1 >: V <: AnyRef](f: (K, V1) => V1): SimpleMap[K, V1]
11+
def mapValuesNow[V1 >: V <: AnyRef](f: (K, V1) => V1): SimpleIdentityMap[K, V1]
1212
def foreachBinding(f: (K, V) => Unit): Unit
1313
def map2[T](f: (K, V) => T): List[T] = {
1414
val buf = new ListBuffer[T]
@@ -23,11 +23,11 @@ abstract class SimpleMap[K <: AnyRef, +V >: Null <: AnyRef] extends (K => V) {
2323
}
2424
}
2525

26-
object SimpleMap {
26+
object SimpleIdentityMap {
2727

2828
private val CompactifyThreshold = 4
2929

30-
private object myEmpty extends SimpleMap[AnyRef, Null] {
30+
private object myEmpty extends SimpleIdentityMap[AnyRef, Null] {
3131
def size = 0
3232
def apply(k: AnyRef) = null
3333
def remove(k: AnyRef) = this
@@ -36,15 +36,15 @@ object SimpleMap {
3636
def foreachBinding(f: (AnyRef, Null) => Unit) = ()
3737
}
3838

39-
def Empty[K <: AnyRef] = myEmpty.asInstanceOf[SimpleMap[K, Null]]
39+
def Empty[K <: AnyRef] = myEmpty.asInstanceOf[SimpleIdentityMap[K, Null]]
4040

41-
class Map1[K <: AnyRef, +V >: Null <: AnyRef] (k1: K, v1: V) extends SimpleMap[K, V] {
41+
class Map1[K <: AnyRef, +V >: Null <: AnyRef] (k1: K, v1: V) extends SimpleIdentityMap[K, V] {
4242
def size = 1
4343
def apply(k: K) =
4444
if (k eq k1) v1
4545
else null
4646
def remove(k: K) =
47-
if (k eq k1) Empty.asInstanceOf[SimpleMap[K, V]]
47+
if (k eq k1) Empty.asInstanceOf[SimpleIdentityMap[K, V]]
4848
else this
4949
def updated[V1 >: V <: AnyRef](k: K, v: V1) =
5050
if (k eq k1) new Map1(k, v)
@@ -56,7 +56,7 @@ object SimpleMap {
5656
def foreachBinding(f: (K, V) => Unit) = f(k1, v1)
5757
}
5858

59-
class Map2[K <: AnyRef, +V >: Null <: AnyRef] (k1: K, v1: V, k2: K, v2: V) extends SimpleMap[K, V] {
59+
class Map2[K <: AnyRef, +V >: Null <: AnyRef] (k1: K, v1: V, k2: K, v2: V) extends SimpleIdentityMap[K, V] {
6060
def size = 2
6161
def apply(k: K) =
6262
if (k eq k1) v1
@@ -78,7 +78,7 @@ object SimpleMap {
7878
def foreachBinding(f: (K, V) => Unit) = { f(k1, v1); f(k2, v2) }
7979
}
8080

81-
class Map3[K <: AnyRef, +V >: Null <: AnyRef] (k1: K, v1: V, k2: K, v2: V, k3: K, v3: V) extends SimpleMap[K, V] {
81+
class Map3[K <: AnyRef, +V >: Null <: AnyRef] (k1: K, v1: V, k2: K, v2: V, k3: K, v3: V) extends SimpleIdentityMap[K, V] {
8282
def size = 3
8383
def apply(k: K) =
8484
if (k eq k1) v1
@@ -103,7 +103,7 @@ object SimpleMap {
103103
def foreachBinding(f: (K, V) => Unit) = { f(k1, v1); f(k2, v2); f(k3, v3) }
104104
}
105105

106-
class Map4[K <: AnyRef, +V >: Null <: AnyRef] (k1: K, v1: V, k2: K, v2: V, k3: K, v3: V, k4: K, v4: V) extends SimpleMap[K, V] {
106+
class Map4[K <: AnyRef, +V >: Null <: AnyRef] (k1: K, v1: V, k2: K, v2: V, k3: K, v3: V, k4: K, v4: V) extends SimpleIdentityMap[K, V] {
107107
def size = 4
108108
def apply(k: K) =
109109
if (k eq k1) v1
@@ -131,7 +131,7 @@ object SimpleMap {
131131
def foreachBinding(f: (K, V) => Unit) = { f(k1, v1); f(k2, v2); f(k3, v3); f(k4, v4) }
132132
}
133133

134-
class MapMore[K <: AnyRef, +V >: Null <: AnyRef](bindings: Array[AnyRef]) extends SimpleMap[K, V] {
134+
class MapMore[K <: AnyRef, +V >: Null <: AnyRef](bindings: Array[AnyRef]) extends SimpleIdentityMap[K, V] {
135135
private def key(i: Int): K = bindings(i).asInstanceOf[K]
136136
private def value(i: Int): V = bindings(i + 1).asInstanceOf[V]
137137

@@ -146,12 +146,12 @@ object SimpleMap {
146146
null
147147
}
148148

149-
def remove(k: K): SimpleMap[K, V] = {
149+
def remove(k: K): SimpleIdentityMap[K, V] = {
150150
var i = 0
151151
while (i < bindings.length) {
152152
if (bindings(i) eq k) return {
153153
if (size == CompactifyThreshold) {
154-
var m: SimpleMap[K, V] = Empty[K]
154+
var m: SimpleIdentityMap[K, V] = Empty[K]
155155
for (j <- 0 until bindings.length by 2)
156156
if (j != i) m = m.updated(key(j), value(j))
157157
m
@@ -167,7 +167,7 @@ object SimpleMap {
167167
this
168168
}
169169

170-
def updated[V1 >: V <: AnyRef](k: K, v: V1): SimpleMap[K, V] = {
170+
def updated[V1 >: V <: AnyRef](k: K, v: V1): SimpleIdentityMap[K, V] = {
171171
var i = 0
172172
while (i < bindings.length) {
173173
if (bindings(i) eq k)

0 commit comments

Comments
 (0)