diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-04-12 10:59:58 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-04-20 08:53:52 +0200 |
commit | 3fca034c51dd159ff077fdde7e3146b1e41cc925 (patch) | |
tree | b68c166936621fe13a3ded46b36408ecb4db52de /src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala | |
parent | 765eb29a769488d56f9ff2e4dde105961dbd55db (diff) | |
download | scala-3fca034c51dd159ff077fdde7e3146b1e41cc925.tar.gz scala-3fca034c51dd159ff077fdde7e3146b1e41cc925.tar.bz2 scala-3fca034c51dd159ff077fdde7e3146b1e41cc925.zip |
Ensure ClassBTypes constructed from symbol and classfile are identical
A super call (invokespecial) to a default method T.m is only allowed if
the interface T is a direct parent of the class. Super calls are
introduced for example in Mixin when generating forwarder methods:
trait T { override def clone(): Object = "hi" }
trait U extends T
class C extends U
The class C gets a forwarder that invokes T.clone(). During code
generation the interface T is added as direct parent to class C. Note
that T is not a (direct) parent in the frontend type of class C.
This commit stores interfaces that are added to a class during code
generation in the InlineInfo classfile attribute. This allows filtering
the interface list when constructing a ClassBType from a classfile.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala index a429cfa0f2..a2c521eb91 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala @@ -1060,8 +1060,10 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { val receiverName = internalName(receiverClass) // super calls are only allowed to direct parents - if (style.isSuper && receiverClass.isTraitOrInterface && !cnode.interfaces.contains(receiverName)) + if (style.isSuper && receiverClass.isTraitOrInterface && !cnode.interfaces.contains(receiverName)) { + thisBType.info.get.inlineInfo.lateInterfaces += receiverName cnode.interfaces.add(receiverName) + } def needsInterfaceCall(sym: Symbol) = { sym.isTraitOrInterface || |