Skip to content

Remove dead code in CapturedVars #4092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2018
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
}
}
}