Skip to content

Commit fad999a

Browse files
committed
Fix isInaccessibleChildOf
1 parent 3e8c9f4 commit fad999a

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

compiler/src/dotty/tools/dotc/transform/SymUtils.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ class SymUtils(val self: Symbol) extends AnyVal {
184184
def isAccessible(sym: Symbol): Boolean =
185185
sym == cls
186186
|| sym == cls.owner
187-
|| sym.owner.is(Package)
188-
|| sym.owner.isType && isAccessible(sym.owner)
189-
!isAccessible(self)
187+
|| sym.is(Package)
188+
|| sym.isType && isAccessible(sym.owner)
189+
!isAccessible(self.owner)
190190

191191
/** If this is a sealed class, its known children in the order of textual occurrence */
192192
def children(implicit ctx: Context): List[Symbol] = {

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,20 +869,19 @@ class Namer { typer: Typer =>
869869
def registerIfChild(denot: SymDenotation)(implicit ctx: Context): Unit = {
870870
val sym = denot.symbol
871871

872-
def register(child: Symbol, parent: Type) = {
872+
def register(child: Symbol, parent: Type) =
873873
val cls = parent.classSymbol
874874
if cls.isEffectivelySealed
875875
&& child.associatedFile == cls.associatedFile // don't register ad-hoc extensions as children
876876
then
877-
if child.isInaccessibleChildOf(cls) && !sym.hasAnonymousChild then
877+
if (child.isInaccessibleChildOf(cls) || child.isAnonymousClass) && !sym.hasAnonymousChild then
878878
addChild(cls, cls)
879879
else if !cls.is(ChildrenQueried) then
880880
addChild(cls, child)
881881
else
882-
ctx.error(em"""children of $cls were already queried before $sym was discovered.
882+
ctx.error(em"""children of $cls were already queried before $sym / ${sym.ownersIterator.toList} was discovered.
883883
|As a remedy, you could move $sym on the same nesting level as $cls.""",
884884
child.sourcePos)
885-
}
886885

887886
if (denot.isClass && !sym.isEnumAnonymClass && !sym.isRefinementClass)
888887
denot.asClass.classParents.foreach { parent =>

0 commit comments

Comments
 (0)