@@ -6,13 +6,18 @@ import Symbols._, Types._, Contexts._, SymDenotations._, DenotTransformers._, Fl
6
6
import util .Positions ._
7
7
import SymUtils ._
8
8
import StdNames ._ , NameOps ._
9
+ import Decorators ._
9
10
10
11
class MixinOps (cls : ClassSymbol , thisTransform : DenotTransformer )(implicit ctx : Context ) {
11
12
import ast .tpd ._
12
13
13
14
val superCls : Symbol = cls.superClass
14
15
val mixins : List [ClassSymbol ] = cls.mixins
15
16
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
+
16
21
def implementation (member : TermSymbol ): TermSymbol = {
17
22
val res = member.copy(
18
23
owner = cls,
@@ -59,10 +64,14 @@ class MixinOps(cls: ClassSymbol, thisTransform: DenotTransformer)(implicit ctx:
59
64
def needsDisambiguation = competingMethods.exists(x=> ! (x is Deferred )) // multiple implementations are available
60
65
def hasNonInterfaceDefinition = competingMethods.exists(! _.owner.is(Trait )) // there is a definition originating from class
61
66
meth.is(Method , butNot = PrivateOrAccessorOrDeferred ) &&
62
- (meth.owner.is(Scala2x ) || needsDisambiguation || hasNonInterfaceDefinition ) &&
67
+ (meth.owner.is(Scala2x ) || needsDisambiguation || hasNonInterfaceDefinition || needsJUnit4Fix(meth) ) &&
63
68
isCurrent(meth)
64
69
}
65
70
71
+ private def needsJUnit4Fix (meth : Symbol ): Boolean = {
72
+ meth.annotations.nonEmpty && JUnit4Annotations .exists(annot => meth.hasAnnotation(annot))
73
+ }
74
+
66
75
/** Get `sym` of the method that needs a forwarder
67
76
* Method needs a forwarder in those cases:
68
77
* - there is a trait that defines a primitive version of implemented polymorphic method.
0 commit comments