@@ -479,34 +479,17 @@ class Namer { typer: Typer =>
479479 // to just prepending the new Child annotation.
480480 def isReady (ann : Annotation ): Boolean =
481481 ann.symbol == defn.ChildAnnot && ! ann.isEvaluating
482- // Forcing a Child annotation may throw `StaleSymbol` if it refers to a
483- // symbol from a previous run that is no longer valid. This happens when
484- // compilation was suspended and the child class is re-typechecked in the
485- // current run, leaving an outdated Child annotation on the parent (see
486- // tests/pos/i24414). Treat such annotations as stale and drop them.
487- def childOf (ann : Annotation ): Option [Symbol ] =
488- try Annotation .Child .unapply(ann)
489- catch case _ : StaleSymbol => None
490482 def insertInto (annots : List [Annotation ]): List [Annotation ] =
491483 annots.find(isReady) match {
492- case Some (ann) =>
493- childOf(ann) match {
494- case Some (other) if other.span.exists && childStart <= other.span.start =>
495- if (child == other)
496- annots // can happen if a class has several inaccessible children
497- else {
498- assert(childStart != other.span.start || child.source != other.source, i " duplicate child annotation $child / $other" )
499- val (prefix, otherAnnot :: rest) = annots.span(a => (a ne ann)): @ unchecked
500- prefix ::: otherAnnot :: insertInto(rest)
501- }
502- case None =>
503- // Drop the stale Child annotation and continue searching.
504- val (prefix, rest) = annots.span(a => (a ne ann))
505- prefix ::: insertInto(rest.tail)
506- case _ =>
507- Annotation .Child (child, cls.span.startPos) :: annots
484+ case Some (Annotation .NonStaleChild (other)) if other.span.exists && childStart <= other.span.start =>
485+ if (child == other)
486+ annots // can happen if a class has several inaccessible children
487+ else {
488+ assert(childStart != other.span.start || child.source != other.source, i " duplicate child annotation $child / $other" )
489+ val (prefix, otherAnnot :: rest) = annots.span(ann => ! isReady(ann)): @ unchecked
490+ prefix ::: otherAnnot :: insertInto(rest)
508491 }
509- case None =>
492+ case _ =>
510493 Annotation .Child (child, cls.span.startPos) :: annots
511494 }
512495 cls.annotations = insertInto(cls.annotations)
0 commit comments