Skip to content

Commit e9d04d0

Browse files
Merge pull request #4092 from dotty-staging/remove-dead-code-4
Remove dead code in CapturedVars
2 parents 79850f7 + 3bea2ce commit e9d04d0

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisPhase =
111111
def boxMethod(name: TermName): Tree =
112112
ref(vble.info.classSymbol.companionModule.info.member(name).symbol)
113113
cpy.ValDef(vdef)(
114-
rhs = vdef.rhs match {
115-
case EmptyTree => boxMethod(nme.zero).appliedToNone.withPos(vdef.pos)
116-
case arg => boxMethod(nme.create).appliedTo(arg)
117-
},
114+
rhs = boxMethod(nme.create).appliedTo(vdef.rhs),
118115
tpt = TypeTree(vble.info).withPos(vdef.tpt.pos))
119116
} else vdef
120117
}

tests/pos/capturedVars2.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
abstract class Test {
2+
3+
var field: Int
4+
val field2: Int
5+
6+
def foo() = {
7+
8+
var x: Int = 1
9+
10+
def inner() = {
11+
x = x + 1 + field + field2
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)