diff options
author | Paul Phillips <paulp@improving.org> | 2012-02-04 21:47:05 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-02-04 22:00:50 -0800 |
commit | 90039fcf18c28a0f89271e6b1fbb6dfd36e1d4ba (patch) | |
tree | eb18754a03d14eba1b1cfcd6191f809b2071f341 /src | |
parent | d5b3c273481a070b9c1e08e0dfeae303ac619292 (diff) | |
download | scala-90039fcf18c28a0f89271e6b1fbb6dfd36e1d4ba.tar.gz scala-90039fcf18c28a0f89271e6b1fbb6dfd36e1d4ba.tar.bz2 scala-90039fcf18c28a0f89271e6b1fbb6dfd36e1d4ba.zip |
Fixing AnyVal verify error and reflection.
Have to give AnyVal a constructor and simultaneously pacify both the
typer (which knows Any has no constructor) and the jvm (which mandates a
constructor must call its superconstructor.) It's the usual angle of
adding a not-quite-right tree during parsing and then finishing it
later (in this case, in AddInterfaces.)
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/AddInterfaces.scala | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index 8fe82258e2..971a0c9aab 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -308,8 +308,13 @@ abstract class AddInterfaces extends InfoTransform { case (presuper, supercall :: rest) => stats span (t => t.hasSymbolWhich(_ hasFlag PRESUPER)) treeCopy.Block(tree, presuper ::: (supercall :: mixinConstructorCalls ::: rest), expr) - case (Nil, Nil) => // AnyVal constructor - Literal(Constant()) + case (Nil, Nil) => + // AnyVal constructor - have to provide a real body so the + // jvm doesn't throw a VerifyError. But we can't add the + // body until now, because the typer knows that Any has no + // constructor and won't accept a call to super.init. + val superCall = Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), Nil) + Block(List(superCall), Literal(Constant())) } } } |