@@ -47,6 +47,19 @@ class SealedDescendantsTest extends DottyTest {
4747 )
4848 end enumOpt
4949
50+ @ Test
51+ def javaEnum : Unit =
52+ expectedDescendents(" java.util.concurrent.TimeUnit" ,
53+ " TimeUnit" ::
54+ " NANOSECONDS.type" ::
55+ " MICROSECONDS.type" ::
56+ " MILLISECONDS.type" ::
57+ " SECONDS.type" ::
58+ " MINUTES.type" ::
59+ " HOURS.type" ::
60+ " DAYS.type" :: Nil
61+ )
62+
5063 @ Test
5164 def hierarchicalSharedChildren : Unit =
5265 // Q is a child of both Z and A and should appear once
@@ -91,10 +104,22 @@ class SealedDescendantsTest extends DottyTest {
91104 )
92105 end hierarchicalSharedChildrenB
93106
94- def expectedDescendents (source : String , root : String , expected : List [String ]) =
95- exploreRoot(source, root) { rootCls =>
96- val descendents = rootCls.sealedDescendants.map(sym => s " ${sym.name}${if (sym.isTerm) " .type" else " " }" )
97- assertEquals(expected.toString, descendents.toString)
107+ def assertMatchingDescenants (rootCls : Symbol , expected : List [String ])(using Context ): Unit =
108+ val descendents = rootCls.sealedDescendants.map(sym => s " ${sym.name}${if (sym.isTerm) " .type" else " " }" )
109+ assertEquals(expected.toString, descendents.toString)
110+
111+ def expectedDescendents (root : String , expected : List [String ]): Unit =
112+ exploreRootNoSource(root)(assertMatchingDescenants(_, expected))
113+
114+ def expectedDescendents (source : String , root : String , expected : List [String ]): Unit =
115+ exploreRoot(source, root)(assertMatchingDescenants(_, expected))
116+
117+ def exploreRootNoSource (root : String )(op : Context ?=> ClassSymbol => Unit ) =
118+ val source1 = s """ package testsealeddescendants
119+ |object Foo { def foo: $root = ??? } """ .stripMargin
120+ checkCompile(" typer" , source1) { (_, context) =>
121+ given Context = context
122+ op(requiredClass(root))
98123 }
99124
100125 def exploreRoot (source : String , root : String )(op : Context ?=> ClassSymbol => Unit ) =
0 commit comments