fails at runtime due to invalid bytecode. This commit turns those into compile time errors. Includes negative test case. git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@19247 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
5d8cf657ec
commit
7770fad82b
|
@ -521,6 +521,10 @@ trait Symbols {
|
|||
/** Does this symbol denote the primary constructor of its enclosing class? */
|
||||
final def isPrimaryConstructor =
|
||||
isConstructor && owner.primaryConstructor == this
|
||||
|
||||
/** Does this symbol denote an auxiliary constructor of its enclosing class? */
|
||||
final def isAuxiliaryConstructor =
|
||||
isConstructor && !isPrimaryConstructor
|
||||
|
||||
/** Is this symbol a synthetic apply or unapply method in a companion object of a case class? */
|
||||
final def isCaseApplyOrUnapply =
|
||||
|
|
|
@ -485,6 +485,11 @@ 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)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
bug1909.scala:5: error: Implementation restriction: auxiliary constructor calls may not use expressions which require lifting.
|
||||
def this(p: String) = this(try 0)
|
||||
^
|
||||
one error found
|
|
@ -0,0 +1,6 @@
|
|||
// Until #1909 is fixed, if this compiles the bytecode
|
||||
// will trigger a VerifyError.
|
||||
class Class {
|
||||
def this(value: Int) = this()
|
||||
def this(p: String) = this(try 0)
|
||||
}
|
Loading…
Reference in New Issue