summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-07-19 00:53:07 -0700
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-07-19 00:53:07 -0700
commitd9b65592df28e8c9655b52c0265f499d757617ba (patch)
tree95b5fe0b226cccae10ea9cd0c6f54baf922aa14e /src
parent92716b54847418565526dc6ec57c6521d1c0c807 (diff)
parent01be1b1c201d6908522d7254075fd1cdf633809a (diff)
downloadscala-d9b65592df28e8c9655b52c0265f499d757617ba.tar.gz
scala-d9b65592df28e8c9655b52c0265f499d757617ba.tar.bz2
scala-d9b65592df28e8c9655b52c0265f499d757617ba.zip
Merge pull request #922 from dragos/issue/fix-SI-6092
SI-6092 don't leak in LazyAnnotationInfo, don't lift try{}finally{}
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala15
-rw-r--r--src/reflect/scala/reflect/internal/AnnotationInfos.scala7
2 files changed, 16 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index de0650b2ea..efc3d25ed0 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -33,6 +33,14 @@ import language.postfixOps
* - convert implicit method types to method types
* - convert non-trivial catches in try statements to matches
* - convert non-local returns to throws with enclosing try statements.
+ * - convert try-catch expressions in contexts where there might be values on the stack to
+ * a local method and a call to it (since an exception empties the evaluation stack):
+ *
+ * meth(x_1,..., try { x_i } catch { ..}, .. x_b0) ==>
+ * {
+ * def liftedTry$1 = try { x_i } catch { .. }
+ * meth(x_1, .., liftedTry$1(), .. )
+ * }
*/
/*</export> */
abstract class UnCurry extends InfoTransform
@@ -634,6 +642,13 @@ abstract class UnCurry extends InfoTransform
case ret @ Return(_) if (isNonLocalReturn(ret)) =>
withNeedLift(true) { super.transform(ret) }
+ case Try(_, Nil, _) =>
+ // try-finally does not need lifting: lifting is needed only for try-catch
+ // expressions that are evaluated in a context where the stack might not be empty.
+ // `finally` does not attempt to continue evaluation after an exception, so the fact
+ // that values on the stack are 'lost' does not matter
+ super.transform(tree)
+
case Try(block, catches, finalizer) =>
if (needTryLift || shouldBeLiftedAnyway(tree)) transform(liftTree(tree))
else super.transform(tree)
diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala
index c283ae408e..2bcc95b9a8 100644
--- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala
+++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala
@@ -160,12 +160,7 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
*/
final class LazyAnnotationInfo(lazyInfo: => AnnotationInfo) extends AnnotationInfo {
private var forced = false
- private lazy val forcedInfo =
- try {
- val result = lazyInfo
- if (result.pos == NoPosition) result setPos pos
- result
- } finally forced = true
+ private lazy val forcedInfo = try lazyInfo finally forced = true
def atp: Type = forcedInfo.atp
def args: List[Tree] = forcedInfo.args