Skip to content

Commit 3cbb5aa

Browse files
committed
Fix #7949: sbt test discovery should not run traits
Traits don't have the `Abstract` flag set, so we need to also check for the `Trait` flag, otherwise https://github.com/sbt/zinc/blob/cdd2a20f110e1eb4a713597b553d57b823466f75/internal/zinc-apiinfo/src/main/scala/xsbt/api/Discovery.scala#L74 will return true for traits, making them eligible for test discovery. Also reorder checks to short-circuit checking for flags when possible.
1 parent 2f719f8 commit 3cbb5aa

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,8 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
583583

584584
def apiModifiers(sym: Symbol): api.Modifiers = {
585585
val absOver = sym.is(AbsOverride)
586-
val abs = sym.is(Abstract) || sym.is(Deferred) || absOver
587-
val over = sym.is(Override) || absOver
586+
val abs = absOver || sym.isOneOf(Trait | Abstract | Deferred)
587+
val over = absOver || sym.is(Override)
588588
new api.Modifiers(abs, over, sym.is(Final), sym.is(Sealed),
589589
sym.isOneOf(GivenOrImplicit), sym.is(Lazy), sym.is(Macro), sym.isSuperAccessor)
590590
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import org.junit.Test
2+
import org.junit.Assert.assertEquals
3+
4+
// Test discovery should not pick this up because it's abstract
5+
abstract class AbstractClassTest {
6+
@Test def foo = {
7+
???
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import org.junit.Test
2+
import org.junit.Assert.assertEquals
3+
4+
// Test discovery should not pick this up because it's a trait
5+
trait TraitTest {
6+
@Test def foo = {
7+
???
8+
}
9+
}

0 commit comments

Comments
 (0)