From cc934ee7bb181645d4436eb923f7eb843b7c259d Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Wed, 28 Oct 2009 17:06:48 +0000 Subject: Fix for #1909 --- src/compiler/scala/tools/nsc/transform/LambdaLift.scala | 6 ++---- src/compiler/scala/tools/nsc/transform/UnCurry.scala | 5 ----- test/files/neg/bug1909.check | 4 ---- test/files/neg/bug1909.scala | 8 -------- test/files/neg/bug1909b.check | 6 +++--- test/files/neg/bug1909b.scala | 3 ++- test/files/pos/bug1909.scala | 8 ++++++++ test/files/pos/bug1909b.scala | 6 ++++++ 8 files changed, 21 insertions(+), 25 deletions(-) delete mode 100644 test/files/neg/bug1909.check delete mode 100644 test/files/neg/bug1909.scala create mode 100644 test/files/pos/bug1909.scala create mode 100644 test/files/pos/bug1909b.scala diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index 69f6cc718e..a6e639b8e7 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -341,10 +341,8 @@ abstract class LambdaLift extends InfoTransform { private def liftDef(tree: Tree): Tree = { val sym = tree.symbol - // A similar check is in UnCurry. - if (sym.owner.isAuxiliaryConstructor && sym.isMethod) - unit.error(tree.pos, "Implementation restriction: auxiliary constructor calls may not use expressions which require lifting.") - + if (sym.owner.isAuxiliaryConstructor && sym.isMethod) // # bug 1909 + sym setFlag STATIC sym.owner = sym.owner.enclClass if (sym.isClass) sym.owner = sym.owner.toInterface if (sym.isMethod) sym setFlag LIFTED diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index bc9c788804..eec523a2b8 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -485,11 +485,6 @@ abstract class UnCurry extends InfoTransform with TypingTransformers { def liftTree(tree: Tree) = { if (settings.debug.value) log("lifting tree at: " + (tree.pos)) - - // Until/unless #1909 is fixed, much better to not compile than to fail at runtime. - if (currentOwner.isAuxiliaryConstructor) - unit.error(tree.pos, "Implementation restriction: auxiliary constructor calls may not use expressions which require lifting.") - val sym = currentOwner.newMethod(tree.pos, unit.fresh.newName(tree.pos, "liftedTree")) sym.setInfo(MethodType(List(), tree.tpe)) new ChangeOwnerTraverser(currentOwner, sym).traverse(tree) diff --git a/test/files/neg/bug1909.check b/test/files/neg/bug1909.check deleted file mode 100644 index 6ffbb4fccc..0000000000 --- a/test/files/neg/bug1909.check +++ /dev/null @@ -1,4 +0,0 @@ -bug1909.scala:7: error: Implementation restriction: auxiliary constructor calls may not use expressions which require lifting. - def this(p: String) = this(try 0) - ^ -one error found diff --git a/test/files/neg/bug1909.scala b/test/files/neg/bug1909.scala deleted file mode 100644 index 01213f62a3..0000000000 --- a/test/files/neg/bug1909.scala +++ /dev/null @@ -1,8 +0,0 @@ -// Until #1909 is fixed, if this compiles the bytecode -// will trigger a VerifyError. This liftings and the one -// in 1909b.scala actually happen in two different places -// (uncurry and lambdalifter.) -class Ticket1909 { - def this(value: Int) = this() - def this(p: String) = this(try 0) -} diff --git a/test/files/neg/bug1909b.check b/test/files/neg/bug1909b.check index d55c5e403b..e5de5fefe9 100644 --- a/test/files/neg/bug1909b.check +++ b/test/files/neg/bug1909b.check @@ -1,4 +1,4 @@ -bug1909b.scala:3: error: Implementation restriction: auxiliary constructor calls may not use expressions which require lifting. - def bar() = 5 - ^ +bug1909b.scala:4: error: this can be used only in a class, object, or template + def bar() = this.z + 5 + ^ one error found diff --git a/test/files/neg/bug1909b.scala b/test/files/neg/bug1909b.scala index b914bee366..6aa7870478 100644 --- a/test/files/neg/bug1909b.scala +++ b/test/files/neg/bug1909b.scala @@ -1,6 +1,7 @@ class Ticket1909 (x: Int) { + var z = 12 def this() = this({ - def bar() = 5 + def bar() = this.z + 5 bar }) } \ No newline at end of file diff --git a/test/files/pos/bug1909.scala b/test/files/pos/bug1909.scala new file mode 100644 index 0000000000..01213f62a3 --- /dev/null +++ b/test/files/pos/bug1909.scala @@ -0,0 +1,8 @@ +// Until #1909 is fixed, if this compiles the bytecode +// will trigger a VerifyError. This liftings and the one +// in 1909b.scala actually happen in two different places +// (uncurry and lambdalifter.) +class Ticket1909 { + def this(value: Int) = this() + def this(p: String) = this(try 0) +} diff --git a/test/files/pos/bug1909b.scala b/test/files/pos/bug1909b.scala new file mode 100644 index 0000000000..b914bee366 --- /dev/null +++ b/test/files/pos/bug1909b.scala @@ -0,0 +1,6 @@ +class Ticket1909 (x: Int) { + def this() = this({ + def bar() = 5 + bar + }) +} \ No newline at end of file -- cgit v1.2.3