Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions compiler/src/dotty/tools/dotc/transform/CapturedVars.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisPhase =
def boxMethod(name: TermName): Tree =
ref(vble.info.classSymbol.companionModule.info.member(name).symbol)
cpy.ValDef(vdef)(
rhs = vdef.rhs match {
case EmptyTree => boxMethod(nme.zero).appliedToNone.withPos(vdef.pos)
case arg => boxMethod(nme.create).appliedTo(arg)
},
rhs = boxMethod(nme.create).appliedTo(vdef.rhs),
tpt = TypeTree(vble.info).withPos(vdef.tpt.pos))
} else vdef
}
Expand Down
14 changes: 14 additions & 0 deletions tests/pos/capturedVars2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
abstract class Test {

var field: Int
val field2: Int

def foo() = {

var x: Int = 1

def inner() = {
x = x + 1 + field + field2
}
}
}