diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2007-01-29 16:07:16 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2007-01-29 16:07:16 +0000 |
commit | 0e147167565d625c7713a6e74c3d58d0ace24439 (patch) | |
tree | c3cac9210fbcae0b33c5190ca015cb08ddbd36c6 | |
parent | 2937f4ebca48d5614b5e1a2ae0aa3dac298010a8 (diff) | |
download | scala-0e147167565d625c7713a6e74c3d58d0ace24439.tar.gz scala-0e147167565d625c7713a6e74c3d58d0ace24439.tar.bz2 scala-0e147167565d625c7713a6e74c3d58d0ace24439.zip |
Fixed the bugfix for returns inside finally
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 2d075005fe..37b2a39ab8 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -457,17 +457,19 @@ abstract class GenICode extends SubComponent { case Return(expr) => val returnedKind = toTypeKind(expr.tpe) var ctx1 = genLoad(expr, ctx, returnedKind) + val oldcleanups = ctx1.cleanups for (val op <- ctx1.cleanups) op match { case MonitorRelease(m) => ctx1.bb.emit(LOAD_LOCAL(m)) ctx1.bb.emit(MONITOR_EXIT()) case Finalizer(f) => + if (settings.debug.value) log("removing " + f + " from cleanups: " + ctx1.cleanups) // we have to run this without the same finalizer in // the list, otherwise infinite recursion happens for // finalizers that contain 'return' ctx1 = genLoad(f, ctx1.removeFinalizer(f), UNIT) - ctx1.addFinalizer(f) } + ctx1.cleanups = oldcleanups ctx1.bb.emit(RETURN(returnedKind), tree.pos) ctx1.bb.enterIgnoreMode @@ -1676,7 +1678,7 @@ abstract class GenICode extends SubComponent { def removeFinalizer(f: Tree): this.type = { assert(cleanups.head == f, - "Illegal nesting of cleanup operations: " + cleanups + " while exiting finalizer" + f); + "Illegal nesting of cleanup operations: " + cleanups + " while exiting finalizer " + f); cleanups = cleanups.tail this } |