@@ -1583,23 +1583,32 @@ object SymDenotations {
15831583 */
15841584 def children (using Context ): List [Symbol ] =
15851585
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+
15921598 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
15941600 c.ensureCompleted()
1601+ end completeChildrenIn
15951602
15961603 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+ }
16031612 setFlag(ChildrenQueried )
16041613
16051614 annotations.collect { case Annotation .Child (child) => child }.reverse
0 commit comments