Skip to content

Commit 4ff0636

Browse files
committed
Add a local val to lifted try to make sure owners are still legal.
Checks the hypothesis that lifting a try may safely move expressions into a ValDef owned by a new temp var.
1 parent edaa193 commit 4ff0636

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/run/liftedTry.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object Tr {
2525
def fun(a: Int => Unit) = a(2)
2626
def foo: Int = {
2727
var s = 1
28-
s = try {fun(s = _); 3} catch{ case ex: Throwable => s = 4; 5 }
28+
s = try {fun(s = _); 3} catch{ case ex: Throwable => val x = 4; s = x; 5 }
2929
s
3030
}
3131
}

0 commit comments

Comments
 (0)