Skip to content

Commit 53eeabf

Browse files
Backport "Consider all parents when checking access to the children of a sum" to LTS (#20767)
Backports #19083 to the LTS branch. PR submitted by the release tooling.
2 parents 65c0a8c + 93976e9 commit 53eeabf

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

compiler/src/dotty/tools/dotc/transform/SymUtils.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ object SymUtils:
173173
else {
174174
val children = self.children
175175
val companionMirror = self.useCompanionAsSumMirror
176-
val ownerScope = if pre.isInstanceOf[SingletonType] then pre.classSymbol else NoSymbol
176+
val ownerScope = if pre.isInstanceOf[SingletonType] then pre.classSymbols else Nil
177177
def problem(child: Symbol) = {
178178

179179
def accessibleMessage(sym: Symbol): String =
@@ -183,8 +183,7 @@ object SymUtils:
183183
self.isContainedIn(sym) || sym.is(Module) && isVisibleToParent(sym.owner)
184184
def isVisibleToScope(sym: Symbol): Boolean =
185185
def isReachable: Boolean = ctx.owner.isContainedIn(sym)
186-
def isMemberOfPrefix: Boolean =
187-
ownerScope.exists && inherits(sym, ownerScope)
186+
def isMemberOfPrefix: Boolean = ownerScope.exists(inherits(sym, _))
188187
isReachable || isMemberOfPrefix || sym.is(Module) && isVisibleToScope(sym.owner)
189188
if !isVisibleToParent(sym) then i"to its parent $self"
190189
else if !companionMirror && !isVisibleToScope(sym) then i"to call site ${ctx.owner}"

tests/pos/i18918.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
trait SuperTrait {
3+
sealed trait InnerTrait
4+
case class Foo() extends InnerTrait
5+
}
6+
7+
trait OtherTrait
8+
9+
trait TraitWithSelfType extends SuperTrait { this: OtherTrait =>
10+
summon[deriving.Mirror.Of[Foo]]
11+
summon[deriving.Mirror.Of[InnerTrait]]
12+
}
13+
14+
object Implementation extends TraitWithSelfType, OtherTrait {
15+
summon[deriving.Mirror.Of[Foo]]
16+
summon[deriving.Mirror.Of[InnerTrait]]
17+
}

0 commit comments

Comments
 (0)