@@ -48,33 +48,40 @@ class MixinOps(cls: ClassSymbol, thisPhase: DenotTransformer)(using Context) {
4848      cls.info.nonPrivateMember(sym.name).hasAltWith(_.symbol ==  sym)
4949    }
5050
51-   /**  Does `method` need a forwarder to  in   class `cls` 
52-    *  Method needs a forwarder in those  cases: 
51+   /**  Does `method` need a forwarder in class `cls`?  
52+    *  Method needs a forwarder in these  cases: 
5353   *   - there's a class defining a method with same signature 
5454   *   - there are multiple traits defining method with same signature 
5555   */  
56-   def  needsMixinForwarder (meth : Symbol ):  Boolean  =  { 
56+   def  needsMixinForwarder (meth : Symbol ):  Boolean  = 
5757    lazy  val  competingMethods  =  competingMethodsIterator(meth).toList
5858
59-     def  needsDisambiguation  =  competingMethods.exists(x =>   ! x .is(Deferred )) //  multiple implementations are available
59+     def  needsDisambiguation  =  competingMethods.exists(! _ .is(Deferred )) //  multiple implementations are available
6060    def  hasNonInterfaceDefinition  =  competingMethods.exists(! _.owner.is(Trait )) //  there is a definition originating from class
6161
6262    //  JUnit 4 won't recognize annotated default methods, so always generate a forwarder for them.
6363    def  generateJUnitForwarder :  Boolean  = 
64-       meth.annotations.nonEmpty &&  JUnit4Annotations .exists(annot  =>   meth.hasAnnotation(annot) ) && 
64+       meth.annotations.nonEmpty &&  JUnit4Annotations .exists(meth.hasAnnotation) && 
6565        ctx.settings.mixinForwarderChoices.isAtLeastJunit
6666
6767    //  Similarly, Java serialization won't take into account a readResolve/writeReplace default method.
6868    def  generateSerializationForwarder :  Boolean  = 
6969       (meth.name ==  nme.readResolve ||  meth.name ==  nme.writeReplace) &&  meth.info.paramNamess.flatten.isEmpty
7070
71-     ! meth.isConstructor && 
72-     meth.is(Method , butNot =  PrivateOrAccessorOrDeferred ) && 
73-     (ctx.settings.mixinForwarderChoices.isTruthy ||  meth.owner.is(Scala2x ) ||  needsDisambiguation ||  hasNonInterfaceDefinition || 
74-      generateJUnitForwarder ||  generateSerializationForwarder) && 
75-     isInImplementingClass(meth) && 
76-     ! meth.name.is(InlineAccessorName )
77-   }
71+     ! meth.isConstructor
72+     &&  meth.is(Method , butNot =  PrivateOrAccessorOrDeferred )
73+     &&  (! meth.is(JavaDefined ) ||  ! meth.owner.is(Sealed ) ||  meth.owner.children.contains(cls))
74+     &&  (
75+          ctx.settings.mixinForwarderChoices.isTruthy
76+       ||  meth.owner.is(Scala2x )
77+       ||  needsDisambiguation
78+       ||  hasNonInterfaceDefinition
79+       ||  generateJUnitForwarder
80+       ||  generateSerializationForwarder
81+     )
82+     &&  isInImplementingClass(meth)
83+     &&  ! meth.name.is(InlineAccessorName )
84+   end  needsMixinForwarder 
7885
7986  final  val  PrivateOrAccessor :  FlagSet  =  Private  |  Accessor 
8087  final  val  PrivateOrAccessorOrDeferred :  FlagSet  =  Private  |  Accessor  |  Deferred 
0 commit comments