@@ -1144,7 +1144,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
1144
1144
val isTraitMethodOverridingObjectMember = {
1145
1145
receiver != methodOwner && // fast path - the boolean is used to pick either of these two, if they are the same it does not matter
1146
1146
style.isVirtual &&
1147
- symHelper (receiver).isEmittedInterface &&
1147
+ isEmittedInterface (receiver) &&
1148
1148
defn.ObjectType .decl(method.name).symbol.exists && { // fast path - compute overrideChain on the next line only if necessary
1149
1149
val syms = method.allOverriddenSymbols.toList
1150
1150
! syms.isEmpty && syms.last.owner == defn.ObjectClass
@@ -1160,7 +1160,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
1160
1160
val bmType = asmMethodType(method)
1161
1161
val mdescr = bmType.descriptor
1162
1162
1163
- val isInterface = symHelper (receiverClass).isEmittedInterface
1163
+ val isInterface = isEmittedInterface (receiverClass)
1164
1164
import InvokeStyle ._
1165
1165
if (style == Super ) {
1166
1166
// DOTTY: this differ from how super-calls in traits are handled in the scalac backend,
@@ -1435,7 +1435,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
1435
1435
// Lambdas should be serializable if they implement a SAM that extends Serializable or if they
1436
1436
// implement a scala.Function* class.
1437
1437
val isSerializable = functionalInterface.isSerializable || defn.isFunctionClass(functionalInterface)
1438
- val isInterface = symHelper (lambdaTarget.owner).isEmittedInterface
1438
+ val isInterface = isEmittedInterface (lambdaTarget.owner)
1439
1439
val invokeStyle =
1440
1440
if (lambdaTarget.isStaticMember) asm.Opcodes .H_INVOKESTATIC
1441
1441
else if (lambdaTarget.is(Flags .Private ) || lambdaTarget.isClassConstructor) asm.Opcodes .H_INVOKESPECIAL
@@ -1494,6 +1494,16 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
1494
1494
generatedType
1495
1495
}
1496
1496
}
1497
+
1498
+ /** Does this symbol actually correspond to an interface that will be emitted?
1499
+ * In the backend, this should be preferred over `isInterface` because it
1500
+ * also returns true for the symbols of the fake companion objects we
1501
+ * create for Java-defined classes as well as for Java annotations
1502
+ * which we represent as classes.
1503
+ */
1504
+ private def isEmittedInterface (sym : Symbol ): Boolean = sym.isInterface ||
1505
+ sym.is(Flags .JavaDefined ) && (toDenot(sym).isAnnotation || sym.is(Flags .ModuleClass ) && (sym.companionClass.is(Flags .PureInterface )) || sym.companionClass.is(Flags .Trait ))
1506
+
1497
1507
}
1498
1508
1499
1509
object BCodeBodyBuilder {
0 commit comments