Skip to content

Commit 777aedd

Browse files
committed
Replace spaces in names
1 parent 00fe8dc commit 777aedd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: compiler/src/dotty/tools/dotc/transform/LazyVals.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
5858
else nullables.toList
5959
}
6060

61-
6261
private def initBlock(stats: List[Tree])(using Context): Block = stats match
6362
case Nil => throw new IllegalArgumentException("trying to create an empty Block")
6463
case x :: Nil => Block(List(x), EmptyTree)
@@ -444,7 +443,7 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
444443
def transformMemberDefThreadSafe(x: ValOrDefDef)(using Context): Thicket = {
445444
import dotty.tools.dotc.core.Types._
446445
import dotty.tools.dotc.core.Flags._
447-
446+
448447
assert(!(x.symbol is Mutable))
449448

450449
val runtimeModule = "scala.runtime.LazyVals"
@@ -457,6 +456,7 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
457456
def offsetName(id: Int) = s"${StdNames.nme.LAZY_FIELD_OFFSET}${if (x.symbol.owner.is(Module)) "_m_" else ""}$id".toTermName
458457

459458
val containerName = LazyLocalName.fresh(x.name.asTermName)
459+
val containerNameEscaped = containerName.toString.replace(" ", "$u0020") // escape spaces in names
460460
val containerSymbol = newSymbol(claz, containerName, containerFlags, defn.ObjectType).enteredAfter(this)
461461
containerSymbol.addAnnotation(Annotation(defn.VolatileAnnot)) // private @volatile var _x: AnyRef
462462
containerSymbol.addAnnotations(x.symbol.annotations) // pass annotations from original definition
@@ -475,13 +475,13 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
475475
case Some(info) =>
476476
offsetSymbol = newSymbol(claz, offsetName(info.defs.size), Synthetic, defn.LongType).enteredAfter(this)
477477
offsetSymbol.nn.addAnnotation(Annotation(defn.ScalaStaticAnnot))
478-
val fieldTree = thizClass.select(lazyNme.RLazyVals.getDeclaredField).appliedTo(Literal(Constant(containerName.toString)))
478+
val fieldTree = thizClass.select(lazyNme.RLazyVals.getDeclaredField).appliedTo(Literal(Constant(containerNameEscaped)))
479479
val offsetTree = ValDef(offsetSymbol.nn, getOffset.appliedTo(fieldTree))
480480
info.defs = offsetTree :: info.defs
481481
case None =>
482482
offsetSymbol = newSymbol(claz, offsetName(0), Synthetic, defn.LongType).enteredAfter(this)
483483
offsetSymbol.nn.addAnnotation(Annotation(defn.ScalaStaticAnnot))
484-
val fieldTree = thizClass.select(lazyNme.RLazyVals.getDeclaredField).appliedTo(Literal(Constant(containerName.toString)))
484+
val fieldTree = thizClass.select(lazyNme.RLazyVals.getDeclaredField).appliedTo(Literal(Constant(containerNameEscaped)))
485485
val offsetTree = ValDef(offsetSymbol.nn, getOffset.appliedTo(fieldTree))
486486
appendOffsetDefs += (claz -> new OffsetInfo(List(offsetTree)))
487487

0 commit comments

Comments
 (0)