Skip to content

Commit f08dac9

Browse files
committed
LazyVals - do not rely on absence of name clashes in scope.
Was creating correct code, but was assuming that all objects with the same name share same bits. No need to do it.
1 parent 2f45313 commit f08dac9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/dotty/tools/dotc/transform/LazyVals.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class LazyVals extends MiniPhaseTransform with IdentityDenotTransformer {
3838
/** this map contains mutable state of transformation: OffsetDefs to be appended to companion object definitions,
3939
* and number of bits currently used */
4040
class OffsetInfo(var defs: List[Tree], var ord:Int)
41-
val appendOffsetDefs = mutable.Map.empty[Name, OffsetInfo]
41+
val appendOffsetDefs = mutable.Map.empty[Symbol, OffsetInfo]
4242

4343
override def phaseName: String = "LazyVals"
4444

@@ -64,7 +64,7 @@ class LazyVals extends MiniPhaseTransform with IdentityDenotTransformer {
6464
override def transformTypeDef(tree: TypeDef)(implicit ctx: Context, info: TransformerInfo): Tree = {
6565
if (!tree.symbol.isClass) tree
6666
else {
67-
appendOffsetDefs.get(tree.symbol.name) match {
67+
appendOffsetDefs.get(tree.symbol) match {
6868
case None => tree
6969
case Some(data) =>
7070
val template = tree.rhs.asInstanceOf[Template]
@@ -296,7 +296,7 @@ class LazyVals extends MiniPhaseTransform with IdentityDenotTransformer {
296296
var ord = 0
297297

298298
// compute or create appropriate offsetSymol, bitmap and bits used by current ValDef
299-
appendOffsetDefs.get(companion.name.moduleClassName) match {
299+
appendOffsetDefs.get(companion.moduleClass) match {
300300
case Some(info) =>
301301
val flagsPerLong = 64 / RLazyVals.BITS_PER_LAZY_VAL
302302
info.ord += 1

0 commit comments

Comments
 (0)