Skip to content

Commit b6efacf

Browse files
committed
After boxing its value, a captured var should become a val.
As noted by @sjrd.
1 parent b2e8905 commit b6efacf

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,12 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisTransfo
5959
refMap.getOrElse(cls, refMap(defn.ObjectClass))
6060
}
6161

62-
def capturedType(vble: Symbol)(implicit ctx: Context): Type = {
63-
val oldInfo = vble.denot(ctx.withPhase(thisTransform)).info
64-
refCls(oldInfo.classSymbol, vble.isVolatile).typeRef
65-
}
66-
6762
override def prepareForValDef(vdef: ValDef)(implicit ctx: Context) = {
6863
val sym = vdef.symbol
6964
if (captured contains sym) {
7065
val newd = sym.denot(ctx.withPhase(thisTransform)).copySymDenotation(
71-
info = refCls(sym.info.classSymbol, sym.hasAnnotation(defn.VolatileAnnot)).typeRef)
66+
info = refCls(sym.info.classSymbol, sym.hasAnnotation(defn.VolatileAnnot)).typeRef,
67+
initFlags = sym.flags &~ Mutable)
7268
newd.removeAnnotation(defn.VolatileAnnot)
7369
newd.installAfter(thisTransform)
7470
}

0 commit comments

Comments
 (0)