diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index fcfbba208eb9..0b8a4297edd0 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -1605,10 +1605,10 @@ object SymDenotations { // children that are defined in the same file as their parents. def maybeChild(sym: Symbol) = (sym.isClass && !this.is(JavaDefined) || sym.originDenotation.is(EnumVal)) - && !owner.is(Package) + && (!owner.is(Package) || sym.originDenotation.infoOrCompleter.match case _: SymbolLoaders.SecondCompleter => sym.associatedFile == this.symbol.associatedFile - case _ => false + case _ => false) if owner.isClass then for c <- owner.info.decls.toList if maybeChild(c) do diff --git a/tests/pos/13495.scala b/tests/pos/13495.scala new file mode 100644 index 000000000000..a70864d5ca66 --- /dev/null +++ b/tests/pos/13495.scala @@ -0,0 +1,20 @@ +import scala.annotation.showAsInfix + +object Test { + trait Component + sealed trait Deleted extends Component + + type Deletable[L <: CList] <: CList = L match { + case h &: t => (h | Deleted) &: Deletable[t] + case CNil => CNil + } + + sealed trait CList + sealed trait CNil extends CList + @showAsInfix case class &:[+C <: Component, +L <: CList](h: C, t: L) extends CList + + case class A(x: Int, y: Int) extends Component + case class B(x: Int, y: Int) extends Component + + val x: Deletable[A &: B &: CNil] = ??? +}