Skip to content

Commit 62eb9ee

Browse files
committed
Fix #11276: Scala.js: Take JUnit tests from superclasses/traits into account.
The Scala 2 code uses owner.info.members.filter(m => m.isMethod && m.hasAnnotation(annot)) for the equivalent operation. The code in Scala 3 used `decls` instead of `members`, which is clearly incorrect. This commit fixes the discrepancy. This was tested manually by making sure that > sjsJUnitTests/testOnly org.scalajs.testsuite.javalib.util.ArrayListTest runs 40 tests, and not just 1. It is not clear how to write automated tests for this fix.
1 parent 7aa0fb1 commit 62eb9ee

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/transform/sjs/JUnitBootstrappers.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ class JUnitBootstrappers extends MiniPhase {
304304
ref(param).cast(clazz.typeRef)
305305

306306
private def annotatedMethods(owner: ClassSymbol, annot: Symbol)(using Context): List[Symbol] =
307-
owner.info.decls.filter(m => m.is(Method) && m.hasAnnotation(annot))
307+
owner.info
308+
.membersBasedOnFlags(Method, EmptyFlags)
309+
.filter(_.symbol.hasAnnotation(annot))
310+
.map(_.symbol)
311+
.toList
308312
}
309313

310314
object JUnitBootstrappers {

0 commit comments

Comments
 (0)