@@ -47,6 +47,19 @@ class SealedDescendantsTest extends DottyTest {
47
47
)
48
48
end enumOpt
49
49
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
+
50
63
@ Test
51
64
def hierarchicalSharedChildren : Unit =
52
65
// Q is a child of both Z and A and should appear once
@@ -91,10 +104,22 @@ class SealedDescendantsTest extends DottyTest {
91
104
)
92
105
end hierarchicalSharedChildrenB
93
106
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))
98
123
}
99
124
100
125
def exploreRoot (source : String , root : String )(op : Context ?=> ClassSymbol => Unit ) =
0 commit comments