@@ -790,7 +790,12 @@ abstract class BCodeHelpers extends BCodeIdiomatic {
790
790
*
791
791
* must-single-thread
792
792
*/
793
- private def addForwarder (isRemoteClass : Boolean , jclass : asm.ClassVisitor , moduleClass : Symbol , m : Symbol ): Unit = {
793
+ private def addForwarder (
794
+ isRemoteClass : Boolean ,
795
+ isBridge : Boolean ,
796
+ jclass : asm.ClassVisitor ,
797
+ moduleClass : Symbol ,
798
+ m : Symbol ): Unit = {
794
799
def staticForwarderGenericSignature : String = {
795
800
// scala/bug#3452 Static forwarder generation uses the same erased signature as the method if forwards to.
796
801
// By rights, it should use the signature as-seen-from the module class, and add suitable
@@ -814,8 +819,8 @@ abstract class BCodeHelpers extends BCodeIdiomatic {
814
819
* and we don't know what classes might be subclassing the companion class. See scala/bug#4827.
815
820
*/
816
821
// TODO: evaluate the other flags we might be dropping on the floor here.
817
- // TODO: ACC_SYNTHETIC ?
818
822
val flags = GenBCode .PublicStatic |
823
+ (if (isBridge) asm.Opcodes .ACC_BRIDGE else 0 ) |
819
824
(if (m.isVarargsMethod) asm.Opcodes .ACC_VARARGS else 0 ) |
820
825
(if (m.isDeprecated) asm.Opcodes .ACC_DEPRECATED else 0 )
821
826
@@ -885,7 +890,11 @@ abstract class BCodeHelpers extends BCodeIdiomatic {
885
890
log(s " No forwarder for non-public member $m" )
886
891
else {
887
892
log(s " Adding static forwarder for ' $m' from $jclassName to ' $moduleClass' " )
888
- addForwarder(isRemoteClass, jclass, moduleClass, m)
893
+ addForwarder(isRemoteClass,
894
+ isBridge = m.isBridge,
895
+ jclass,
896
+ moduleClass,
897
+ m)
889
898
}
890
899
}
891
900
}
@@ -1161,7 +1170,12 @@ object BCodeHelpers {
1161
1170
val ExcludedForwarderFlags = {
1162
1171
import scala .tools .nsc .symtab .Flags ._
1163
1172
// Should include DEFERRED but this breaks findMember.
1164
- SPECIALIZED | LIFTED | PROTECTED | STATIC | EXPANDEDNAME | BridgeAndPrivateFlags | MACRO
1173
+ // Note that BRIDGE is *not* excluded. Trying to exclude bridges by flag doesn't work, findMembers
1174
+ // will then include the member from the parent (which the bridge overrides / implements).
1175
+ // This caused scala/bug#11061 and scala/bug#10812. In 2.13, they are fixed by not emitting
1176
+ // forwarders for bridges. But in 2.12 that's not binary compatible, so instead we continue to
1177
+ // emit forwarders for bridges, but mark them with ACC_BRIDGE.
1178
+ SPECIALIZED | LIFTED | PROTECTED | STATIC | EXPANDEDNAME | PRIVATE | MACRO
1165
1179
}
1166
1180
1167
1181
/**
0 commit comments