From 3fca034c51dd159ff077fdde7e3146b1e41cc925 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Tue, 12 Apr 2016 10:59:58 +0200 Subject: 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. --- .../nsc/backend/jvm/opt/BTypesFromClassfileTest.scala | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'test/junit/scala/tools/nsc/backend/jvm/opt/BTypesFromClassfileTest.scala') diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/BTypesFromClassfileTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/BTypesFromClassfileTest.scala index 1ce913006d..9e6a148dba 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/opt/BTypesFromClassfileTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/opt/BTypesFromClassfileTest.scala @@ -67,19 +67,7 @@ class BTypesFromClassfileTest { // there's a separate InlineInfoTest. val chk1 = sameBTypes(fromSym.superClass, fromClassfile.superClass, checked) - - // was: - // val chk2 = sameBTypes(fromSym.interfaces, fromClassfile.interfaces, chk1) - - // TODO: The new trait encoding emits redundant parents in the backend to avoid linkage errors in invokespecial - // Need to give this some more thought, maybe do it earlier so it is reflected in the Symbol's info, too. - val fromSymInterfaces = fromSym.interfaces - val fromClassFileInterfaces = fromClassfile.interfaces - val (matching, other) = fromClassFileInterfaces.partition(x => fromSymInterfaces.exists(_.internalName == x.internalName)) - val chk2 = sameBTypes(fromSym.interfaces, matching, chk1) - for (redundant <- other) { - assert(matching.exists(x => x.isSubtypeOf(redundant).orThrow), redundant) - } + val chk2 = sameBTypes(fromSym.interfaces, fromClassfile.interfaces, chk1) // The fromSym info has only member classes, no local or anonymous. The symbol is read from the // Scala pickle data and only member classes are created / entered. -- cgit v1.2.3