summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/AddInterfaces.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/AddInterfaces.scala20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
index 1abaf1c1d6..71d595c9c4 100644
--- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
+++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
@@ -299,15 +299,25 @@ abstract class AddInterfaces extends InfoTransform {
}
val mixinConstructorCalls: List[Tree] = {
for (mc <- clazz.mixinClasses.reverse
- if mc.hasFlag(lateINTERFACE) && mc != ScalaObjectClass)
+ if mc.hasFlag(lateINTERFACE))
yield mixinConstructorCall(implClass(mc))
}
- (tree: @unchecked) match {
+ tree match {
case Block(stats, expr) =>
// needs `hasSymbol` check because `supercall` could be a block (named / default args)
- val (presuper, supercall :: rest) = stats span (t => t.hasSymbolWhich(_ hasFlag PRESUPER))
- // assert(supercall.symbol.isClassConstructor, supercall)
- treeCopy.Block(tree, presuper ::: (supercall :: mixinConstructorCalls ::: rest), expr)
+ stats span (t => t.hasSymbolWhich(_ hasFlag PRESUPER)) match {
+ case (presuper, supercall :: rest) =>
+ stats span (t => t.hasSymbolWhich(_ hasFlag PRESUPER))
+ treeCopy.Block(tree, presuper ::: (supercall :: mixinConstructorCalls ::: rest), expr)
+ case (Nil, Nil) =>
+ assert(clazz eq AnyValClass, clazz)
+ // 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()))
+ }
}
}