@@ -1583,23 +1583,32 @@ object SymDenotations {
1583
1583
*/
1584
1584
def children (using Context ): List [Symbol ] =
1585
1585
1586
- def completeChildrenIn (owner : Symbol ) =
1587
- def maybeChild (c : Symbol ) =
1588
- ! owner.is(Package )
1589
- || c.infoOrCompleter.match
1590
- case _ : SymbolLoaders .SecondCompleter => c.associatedFile == symbol.associatedFile
1591
- case _ => false
1586
+ def completeChildrenIn (owner : Symbol )(using Context ) =
1587
+ // Possible children are: classes extending Scala classes and
1588
+ // Scala or Java enum values that are defined in owner.
1589
+ // If owner is a package, we complete only
1590
+ // children that are defined in the same file as their parents.
1591
+ def maybeChild (sym : Symbol ) =
1592
+ (sym.isClass && ! this .is(JavaDefined ) || sym.is(EnumVal ))
1593
+ && ! owner.is(Package )
1594
+ || sym.infoOrCompleter.match
1595
+ case _ : SymbolLoaders .SecondCompleter => sym.associatedFile == this .symbol.associatedFile
1596
+ case _ => false
1597
+
1592
1598
if owner.isClass then
1593
- for c <- owner.info.decls.toList if c.isClass && maybeChild(c) do
1599
+ for c <- owner.info.decls.toList if maybeChild(c) do
1594
1600
c.ensureCompleted()
1601
+ end completeChildrenIn
1595
1602
1596
1603
if is(Sealed ) then
1597
- if ! is(ChildrenQueried ) && ! ctx.isAfterTyper then
1598
- // During typer, make sure all visible children are completed, so that
1599
- // they show up in Child annotations. A class is visible if it is defined
1600
- // in the same scope as `cls` or in the companion object of `cls`.
1601
- completeChildrenIn(owner)
1602
- completeChildrenIn(companionClass)
1604
+ if ! is(ChildrenQueried ) then
1605
+ // Make sure all visible children are completed, so that
1606
+ // they show up in Child annotations. A possible child is visible if it
1607
+ // is defined in the same scope as `cls` or in the companion object of `cls`.
1608
+ inContext(ctx.withPhase(ctx.typerPhase)) {
1609
+ completeChildrenIn(owner)
1610
+ completeChildrenIn(companionClass)
1611
+ }
1603
1612
setFlag(ChildrenQueried )
1604
1613
1605
1614
annotations.collect { case Annotation .Child (child) => child }.reverse
0 commit comments