summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/transform/LambdaLift.scala6
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala5
-rw-r--r--test/files/neg/bug1909.check4
-rw-r--r--test/files/neg/bug1909b.check6
-rw-r--r--test/files/neg/bug1909b.scala3
-rw-r--r--test/files/pos/bug1909.scala (renamed from test/files/neg/bug1909.scala)0
-rw-r--r--test/files/pos/bug1909b.scala6
7 files changed, 13 insertions, 17 deletions
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/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/neg/bug1909.scala b/test/files/pos/bug1909.scala
index 01213f62a3..01213f62a3 100644
--- a/test/files/neg/bug1909.scala
+++ b/test/files/pos/bug1909.scala
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