Skip to content

Commit 0b4074d

Browse files
committed
Handle duplicate children
1 parent b3b26e2 commit 0b4074d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,13 @@ class Namer { typer: Typer =>
509509
def insertInto(annots: List[Annotation]): List[Annotation] =
510510
annots.find(_.symbol == defn.ChildAnnot) match {
511511
case Some(Annotation.Child(other)) if childStart <= other.pos.start =>
512-
assert(childStart != other.pos.start, "duplicate child annotation $child / $other")
513-
val (prefix, otherAnnot :: rest) = annots.span(_.symbol != defn.ChildAnnot)
514-
prefix ::: otherAnnot :: insertInto(rest)
512+
if (child == other)
513+
annots // can happen if a class has several inaccessible children
514+
else {
515+
assert(childStart != other.pos.start, i"duplicate child annotation $child / $other")
516+
val (prefix, otherAnnot :: rest) = annots.span(_.symbol != defn.ChildAnnot)
517+
prefix ::: otherAnnot :: insertInto(rest)
518+
}
515519
case _ =>
516520
Annotation.Child(child) :: annots
517521
}

0 commit comments

Comments
 (0)