Skip to content

Commit d3bead9

Browse files
committed
LazyValues: minor post-erasure changes.
1 parent 6c5beea commit d3bead9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class LazyVals extends MiniPhaseTransform with IdentityDenotTransformer {
6868
case None => tree
6969
case Some(data) =>
7070
val template = tree.rhs.asInstanceOf[Template]
71-
ClassDef(tree.symbol.asClass, template.constr, data.defs.mapConserve(transformFollowingDeep) ::: template.body)
71+
val newTemplate = cpy.Template(template)(body = data.defs ::: template.body)
72+
cpy.TypeDef(tree)(rhs = newTemplate) //(ctx.withMode(Mode.FutureDefsOK))
7273
}
7374
}
7475
}
@@ -168,7 +169,7 @@ class LazyVals extends MiniPhaseTransform with IdentityDenotTransformer {
168169
val containerSymbol = ctx.newSymbol(claz, containerName, (x.mods &~ containerFlagsMask | containerFlags).flags, tpe, coord = x.symbol.coord).enteredAfter(this)
169170

170171
val containerTree = ValDef(containerSymbol, initValue(tpe))
171-
if (x.tpe.isNotNull && tpe <:< defn.AnyRefType) { // can use 'null' value instead of flag
172+
if (x.tpe.isNotNull && tpe <:< defn.ObjectType) { // can use 'null' value instead of flag
172173
val slowPath = DefDef(x.symbol.asTerm, mkDefNonThreadSafeNonNullable(containerSymbol, x.rhs))
173174
Thicket(List(containerTree, slowPath))
174175
}

0 commit comments

Comments
 (0)