aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/src/dotty/tools/dotc/core/NameKinds.scala3
-rw-r--r--compiler/src/dotty/tools/dotc/core/Names.scala3
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/NameKinds.scala b/compiler/src/dotty/tools/dotc/core/NameKinds.scala
index bee39adaa..0f08e4701 100644
--- a/compiler/src/dotty/tools/dotc/core/NameKinds.scala
+++ b/compiler/src/dotty/tools/dotc/core/NameKinds.scala
@@ -13,6 +13,9 @@ import collection.mutable
object NameKinds {
+ // These are sharable since all NameKinds are created eagerly at the start of the program
+ // before any concurrent threads are forked. for this to work, NameKinds should never
+ // be created lazily or in modules that start running after compilers are forked.
@sharable private val simpleNameKinds = new mutable.HashMap[Int, ClassifiedNameKind]
@sharable private val qualifiedNameKinds = new mutable.HashMap[Int, QualifiedNameKind]
@sharable private val uniqueNameKinds = new mutable.HashMap[String, UniqueNameKind]
diff --git a/compiler/src/dotty/tools/dotc/core/Names.scala b/compiler/src/dotty/tools/dotc/core/Names.scala
index cef55a482..a72a02844 100644
--- a/compiler/src/dotty/tools/dotc/core/Names.scala
+++ b/compiler/src/dotty/tools/dotc/core/Names.scala
@@ -134,7 +134,8 @@ object Names {
def info: NameInfo = SimpleTermNameKind.info
def underlying: TermName = unsupported("underlying")
- @sharable private var derivedNames: AnyRef /* SimpleMap | j.u.HashMap */ =
+ @sharable // because of synchronized block in `and`
+ private var derivedNames: AnyRef /* SimpleMap | j.u.HashMap */ =
SimpleMap.Empty[NameInfo]
private def getDerived(info: NameInfo): DerivedTermName /* | Null */= derivedNames match {