Skip to content

Commit

Permalink
Backport "Consider all parents when checking access to the children o…
Browse files Browse the repository at this point in the history
…f a sum" to LTS (#20767)

Backports #19083 to the LTS branch.

PR submitted by the release tooling.
  • Loading branch information
WojciechMazur authored Jun 23, 2024
2 parents 65c0a8c + 93976e9 commit 53eeabf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/transform/SymUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ object 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 =
Expand All @@ -183,8 +183,7 @@ object 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}"
Expand Down
17 changes: 17 additions & 0 deletions tests/pos/i18918.scala
Original file line number Diff line number Diff line change
@@ -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]]
}

0 comments on commit 53eeabf

Please sign in to comment.