Given this question and SI-7046, this isn't at all what I expected.
scalac test.scala && scala Test
in Scala 2.11.6 on the following prints an empty Set()
:
trait Foo
case class Bar() extends Foo
case class Baz() extends Foo
object Test {
def main(args: Array[String]) {
println( typeOf[Foo].typeSymbol.asClass.knownDirectSubclasses )
}
}
However, if I change trait Foo
to sealed trait Foo
, it prints Set(class Bar, class Baz)
as expected.
What's going on here?
Aucun commentaire:
Enregistrer un commentaire