Skip to content

Commit e7721a9

Browse files
committed
Rename nextId -> nextSymId in Context
... preparing to add a nextTreeId as well.
1 parent 4d10f68 commit e7721a9

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

compiler/src/dotty/tools/dotc/ast/Positioned.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools.dotc
22
package ast
33

44
import util.Positions._
5-
import core.Contexts.Context
5+
import core.Contexts.{Context, TreeIds}
66
import core.Decorators._
77
import core.Flags.{JavaDefined, Extension}
88
import core.StdNames.nme
@@ -27,24 +27,26 @@ abstract class Positioned extends Product {
2727
if (pos.exists) setChildPositions(pos.toSynthetic)
2828
}
2929

30+
def cloned(implicit ids: TreeIds): Positioned
31+
3032
/** A positioned item like this one with the position set to `pos`.
3133
* if the positioned item is source-derived, a clone is returned.
3234
* If the positioned item is synthetic, the position is updated
3335
* destructively and the item itself is returned.
3436
*/
35-
def withPos(pos: Position): this.type = {
36-
val newpd = (if (pos == curPos || curPos.isSynthetic) this else clone.asInstanceOf[Positioned])
37+
def withPos(pos: Position)(implicit ids: TreeIds): this.type = {
38+
val newpd = if (pos == curPos || curPos.isSynthetic) this else cloned
3739
newpd.setPos(pos)
3840
newpd.asInstanceOf[this.type]
3941
}
4042

41-
def withPos(posd: Positioned): this.type =
43+
def withPos(posd: Positioned)(implicit ids: TreeIds): this.type =
4244
if (posd == null) this else withPos(posd.pos)
4345

4446
/** This item with a position that's the union of the given `pos` and the
4547
* current position.
4648
*/
47-
def addPos(pos: Position): this.type = withPos(pos union this.pos)
49+
def addPos(pos: Position)(implicit ids: TreeIds): this.type = withPos(pos union this.pos)
4850

4951
/** Set position of this tree only, without performing
5052
* any checks of consistency with - or updates of - other positions.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ object Contexts {
455455
def pendingUnderlying: mutable.HashSet[Type] = base.pendingUnderlying
456456
def uniqueNamedTypes: Uniques.NamedTypeUniques = base.uniqueNamedTypes
457457
def uniques: util.HashSet[Type] = base.uniques
458-
def nextId: Int = base.nextId
458+
def nextSymId: Int = base.nextSymId
459459

460460
def initialize()(implicit ctx: Context): Unit = base.initialize()(ctx)
461461
}
@@ -626,9 +626,9 @@ object Contexts {
626626
// Symbols state
627627

628628
/** A counter for unique ids */
629-
private[core] var _nextId: Int = 0
629+
private[core] var _nextSymId: Int = 0
630630

631-
def nextId: Int = { _nextId += 1; _nextId }
631+
def nextSymId: Int = { _nextSymId += 1; _nextSymId }
632632

633633
/** Sources that were loaded */
634634
val sources: mutable.HashMap[AbstractFile, SourceFile] = new mutable.HashMap[AbstractFile, SourceFile]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ trait Symbols { this: Context =>
4343
* it's debug-friendlier not to create an anonymous class here.
4444
*/
4545
def newNakedSymbol[N <: Name](coord: Coord = NoCoord)(implicit ctx: Context): Symbol { type ThisName = N } =
46-
new Symbol(coord, ctx.nextId).asInstanceOf[Symbol { type ThisName = N }]
46+
new Symbol(coord, ctx.nextSymId).asInstanceOf[Symbol { type ThisName = N }]
4747

4848
/** Create a class symbol without a denotation. */
4949
def newNakedClassSymbol(coord: Coord = NoCoord, assocFile: AbstractFile = null)(implicit ctx: Context): ClassSymbol =
50-
new ClassSymbol(coord, assocFile, ctx.nextId)
50+
new ClassSymbol(coord, assocFile, ctx.nextSymId)
5151

5252
// ---- Symbol creation methods ----------------------------------
5353

0 commit comments

Comments
 (0)