summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2010-01-07 11:00:20 +0000
committerIulian Dragos <jaguarul@gmail.com>2010-01-07 11:00:20 +0000
commit57f14277dad0427b90abc1e6f70e2f8ae4dcbb51 (patch)
tree36b1d1cc5f30a28edab08120d2f2f21d3eef4f97 /src
parent7315339782f6e19ddd6199768352a91ef66eb27d (diff)
downloadscala-57f14277dad0427b90abc1e6f70e2f8ae4dcbb51.tar.gz
scala-57f14277dad0427b90abc1e6f70e2f8ae4dcbb51.tar.bz2
scala-57f14277dad0427b90abc1e6f70e2f8ae4dcbb51.zip
Fixed #2850 -- while inside finally causes Veri...
Fixed #2850 -- while inside finally causes VerifyError, review by rytz
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 4e6507f9e3..cd690097e8 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -1621,8 +1621,9 @@ abstract class GenICode extends SubComponent {
override def equals(other: Any) = f == other;
}
- def duplicateFinalizer(ctx: Context, finalizer: Tree) =
- (new DuplicateLabels(ctx.labels.keySet))(ctx, finalizer)
+ def duplicateFinalizer(boundLabels: collection.Set[Symbol], targetCtx: Context, finalizer: Tree) = {
+ (new DuplicateLabels(boundLabels))(targetCtx, finalizer)
+ }
/**
* The Context class keeps information relative to the current state
@@ -1863,6 +1864,10 @@ abstract class GenICode extends SubComponent {
var tmp: Local = null
val kind = toTypeKind(tree.tpe)
val guardResult = kind != UNIT && mayCleanStack(finalizer)
+ // we need to save bound labels before any code generation is performed on
+ // the current context (otherwise, any new lables in the finalizer that need to
+ // be duplicated would be incorrectly considered bound -- see #2850).
+ val boundLabels: collection.Set[Symbol] = Set.empty ++ labels.keySet
if (guardResult) {
tmp = this.makeLocal(tree.pos, tree.tpe, "tmp")
@@ -1875,11 +1880,11 @@ abstract class GenICode extends SubComponent {
if (guardResult) {
ctx1.bb.emit(STORE_LOCAL(tmp))
- val ctx2 = genLoad(duplicateFinalizer(ctx1, finalizer), ctx1, UNIT)
+ val ctx2 = genLoad(duplicateFinalizer(boundLabels, ctx1, finalizer), ctx1, UNIT)
ctx2.bb.emit(LOAD_LOCAL(tmp))
ctx2
} else
- genLoad(duplicateFinalizer(ctx1, finalizer), ctx1, UNIT)
+ genLoad(duplicateFinalizer(boundLabels, ctx1, finalizer), ctx1, UNIT)
} else ctx