Skip to content

Commit a6c6a89

Browse files
committed
Protect concurrent accesses to JSDefinitions.cache.
1 parent 3a5897b commit a6c6a89

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/dotty/tools/backend/sjs/JSDefinitions.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ package dotty.tools.backend.sjs
22

33
import dotty.tools.dotc.core._
44

5-
import Types._, Contexts._, Symbols._, Denotations._, SymDenotations._, StdNames._, Names._
6-
import Flags._, Scopes._, Decorators._, NameOps._, Periods._
5+
import Types._
6+
import Contexts._
7+
import Symbols._
8+
import StdNames._
9+
import Decorators._
710

811
object JSDefinitions {
12+
@dotty.tools.sharable
913
private val cache = new java.util.WeakHashMap[ContextBase, JSDefinitions]
1014

1115
// TODO Figure out where best to define this
12-
def jsdefn(implicit ctx: Context): JSDefinitions = {
16+
def jsdefn(implicit ctx: Context): JSDefinitions = cache.synchronized {
1317
val baseCtx = ctx.base
1418
val cached = cache.get(baseCtx)
1519
if (cached != null) {

0 commit comments

Comments
 (0)