Skip to content

Commit bec4f9d

Browse files
committed
Better documentation of sharable structures in Names, NameKinds
1 parent a5b6bd6 commit bec4f9d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import collection.mutable
1313

1414
object NameKinds {
1515

16+
// These are sharable since all NameKinds are created eagerly at the start of the program
17+
// before any concurrent threads are forked. for this to work, NameKinds should never
18+
// be created lazily or in modules that start running after compilers are forked.
1619
@sharable private val simpleNameKinds = new mutable.HashMap[Int, ClassifiedNameKind]
1720
@sharable private val qualifiedNameKinds = new mutable.HashMap[Int, QualifiedNameKind]
1821
@sharable private val uniqueNameKinds = new mutable.HashMap[String, UniqueNameKind]

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ object Names {
134134
def info: NameInfo = SimpleTermNameKind.info
135135
def underlying: TermName = unsupported("underlying")
136136

137-
@sharable private var derivedNames: AnyRef /* SimpleMap | j.u.HashMap */ =
137+
@sharable // because of synchronized block in `and`
138+
private var derivedNames: AnyRef /* SimpleMap | j.u.HashMap */ =
138139
SimpleMap.Empty[NameInfo]
139140

140141
private def getDerived(info: NameInfo): DerivedTermName /* | Null */= derivedNames match {

0 commit comments

Comments
 (0)