diff --git a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala index 353ebee25c29..e51c5cd5316c 100644 --- a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala +++ b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala @@ -109,7 +109,11 @@ object SymUtils: def problem(child: Symbol) = { def isAccessible(sym: Symbol): Boolean = - (self.isContainedIn(sym) && (companionMirror || declScope.isContainedIn(sym))) + self.isContainedIn(sym) && + (companionMirror + || declScope.isContainedIn(sym) + || declScope.ownersIterator.exists(_.isSubClass(sym)) + ) || sym.is(Module) && isAccessible(sym.owner) if (child == self) "it has anonymous or inaccessible subclasses" diff --git a/tests/pos/i13332.scala b/tests/pos/i13332.scala new file mode 100644 index 000000000000..9793a7903362 --- /dev/null +++ b/tests/pos/i13332.scala @@ -0,0 +1,15 @@ +import scala.deriving.Mirror + +class Scope extends IListDefn { + + type Of = Mirror { type MirroredType[X] = IList[X]; type MirroredMonoType = IList[Any] ; type MirroredElemTypes[_] <: Tuple } + + val M = summon[Of] +} + + +trait IListDefn { + sealed trait IList[A] + case class INil[A]() extends IList[A] + case class ICons[A](h: A, t: IList[A]) extends IList[A] +}