diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/LambdaLift.scala | 4 | ||||
-rw-r--r-- | test/files/neg/bug1909.check | 2 | ||||
-rw-r--r-- | test/files/neg/bug1909.scala | 8 | ||||
-rw-r--r-- | test/files/neg/bug1909b.check | 4 | ||||
-rw-r--r-- | test/files/neg/bug1909b.scala | 6 |
5 files changed, 20 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index d962dba63f..69f6cc718e 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -341,6 +341,10 @@ 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.") + sym.owner = sym.owner.enclClass if (sym.isClass) sym.owner = sym.owner.toInterface if (sym.isMethod) sym setFlag LIFTED diff --git a/test/files/neg/bug1909.check b/test/files/neg/bug1909.check index 631c60d5f0..6ffbb4fccc 100644 --- a/test/files/neg/bug1909.check +++ b/test/files/neg/bug1909.check @@ -1,4 +1,4 @@ -bug1909.scala:5: error: Implementation restriction: auxiliary constructor calls may not use expressions which require lifting. +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 index 4fae4e5414..01213f62a3 100644 --- a/test/files/neg/bug1909.scala +++ b/test/files/neg/bug1909.scala @@ -1,6 +1,8 @@ // Until #1909 is fixed, if this compiles the bytecode -// will trigger a VerifyError. -class Class { +// 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) -}
\ No newline at end of file +} diff --git a/test/files/neg/bug1909b.check b/test/files/neg/bug1909b.check new file mode 100644 index 0000000000..d55c5e403b --- /dev/null +++ b/test/files/neg/bug1909b.check @@ -0,0 +1,4 @@ +bug1909b.scala:3: error: Implementation restriction: auxiliary constructor calls may not use expressions which require lifting. + def bar() = 5 + ^ +one error found diff --git a/test/files/neg/bug1909b.scala b/test/files/neg/bug1909b.scala new file mode 100644 index 0000000000..b914bee366 --- /dev/null +++ b/test/files/neg/bug1909b.scala @@ -0,0 +1,6 @@ +class Ticket1909 (x: Int) { + def this() = this({ + def bar() = 5 + bar + }) +}
\ No newline at end of file |