Fix for #1909
git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@19331 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
7f662011d4
commit
e28ec6cf89
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class Ticket1909 (x: Int) {
|
||||
var z = 12
|
||||
def this() = this({
|
||||
def bar() = 5
|
||||
def bar() = this.z + 5
|
||||
bar
|
||||
})
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
class Ticket1909 (x: Int) {
|
||||
def this() = this({
|
||||
def bar() = 5
|
||||
bar
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue