diff --git a/compiler/src/dotty/tools/dotc/core/SymUtils.scala b/compiler/src/dotty/tools/dotc/core/SymUtils.scala index e0e5c7a7cb87..65634241b790 100644 --- a/compiler/src/dotty/tools/dotc/core/SymUtils.scala +++ b/compiler/src/dotty/tools/dotc/core/SymUtils.scala @@ -181,7 +181,7 @@ class SymUtils: else { val children = self.children val companionMirror = self.useCompanionAsSumMirror - val ownerScope = if pre.isInstanceOf[SingletonType] then pre.classSymbol else NoSymbol + val ownerScope = if pre.isInstanceOf[SingletonType] then pre.classSymbols else Nil def problem(child: Symbol) = { def accessibleMessage(sym: Symbol): String = @@ -191,8 +191,7 @@ class SymUtils: self.isContainedIn(sym) || sym.is(Module) && isVisibleToParent(sym.owner) def isVisibleToScope(sym: Symbol): Boolean = def isReachable: Boolean = ctx.owner.isContainedIn(sym) - def isMemberOfPrefix: Boolean = - ownerScope.exists && inherits(sym, ownerScope) + def isMemberOfPrefix: Boolean = ownerScope.exists(inherits(sym, _)) isReachable || isMemberOfPrefix || sym.is(Module) && isVisibleToScope(sym.owner) if !isVisibleToParent(sym) then i"to its parent $self" else if !companionMirror && !isVisibleToScope(sym) then i"to call site ${ctx.owner}" diff --git a/tests/pos/i18918.scala b/tests/pos/i18918.scala new file mode 100644 index 000000000000..0ec6f29b2b89 --- /dev/null +++ b/tests/pos/i18918.scala @@ -0,0 +1,17 @@ + +trait SuperTrait { + sealed trait InnerTrait + case class Foo() extends InnerTrait +} + +trait OtherTrait + +trait TraitWithSelfType extends SuperTrait { this: OtherTrait => + summon[deriving.Mirror.Of[Foo]] + summon[deriving.Mirror.Of[InnerTrait]] +} + +object Implementation extends TraitWithSelfType, OtherTrait { + summon[deriving.Mirror.Of[Foo]] + summon[deriving.Mirror.Of[InnerTrait]] +}