@@ -6,13 +6,18 @@ import Symbols._, Types._, Contexts._, SymDenotations._, DenotTransformers._, Fl
66import util .Positions ._
77import SymUtils ._
88import StdNames ._ , NameOps ._
9+ import Decorators ._
910
1011class MixinOps (cls : ClassSymbol , thisTransform : DenotTransformer )(implicit ctx : Context ) {
1112 import ast .tpd ._
1213
1314 val superCls : Symbol = cls.superClass
1415 val mixins : List [ClassSymbol ] = cls.mixins
1516
17+ lazy val JUnit4Annotations : List [Symbol ] = List (" Test" , " Ignore" , " Before" , " After" , " BeforeClass" , " AfterClass" ).
18+ map(n => ctx.getClassIfDefined(" org.junit." + n)).
19+ filter(_.exists)
20+
1621 def implementation (member : TermSymbol ): TermSymbol = {
1722 val res = member.copy(
1823 owner = cls,
@@ -59,10 +64,14 @@ class MixinOps(cls: ClassSymbol, thisTransform: DenotTransformer)(implicit ctx:
5964 def needsDisambiguation = competingMethods.exists(x=> ! (x is Deferred )) // multiple implementations are available
6065 def hasNonInterfaceDefinition = competingMethods.exists(! _.owner.is(Trait )) // there is a definition originating from class
6166 meth.is(Method , butNot = PrivateOrAccessorOrDeferred ) &&
62- (meth.owner.is(Scala2x ) || needsDisambiguation || hasNonInterfaceDefinition ) &&
67+ (meth.owner.is(Scala2x ) || needsDisambiguation || hasNonInterfaceDefinition || needsJUnit4Fix(meth) ) &&
6368 isCurrent(meth)
6469 }
6570
71+ private def needsJUnit4Fix (meth : Symbol ): Boolean = {
72+ meth.annotations.nonEmpty && JUnit4Annotations .exists(annot => meth.hasAnnotation(annot))
73+ }
74+
6675 /** Get `sym` of the method that needs a forwarder
6776 * Method needs a forwarder in those cases:
6877 * - there is a trait that defines a primitive version of implemented polymorphic method.
0 commit comments