Skip to content

Commit ddb8098

Browse files
committed
Allow going from non-priv to priv denot when run changes
1 parent 1821944 commit ddb8098

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ object Types {
14821482

14831483
/** A member of `prefix` (disambiguated by `d.signature`) or, if none was found, `d.current`. */
14841484
private def recomputeMember(d: SymDenotation)(implicit ctx: Context): Denotation =
1485-
asMemberOf(prefix) match {
1485+
asMemberOf(prefix, allowPrivate = d.is(Private)) match {
14861486
case NoDenotation => d.current
14871487
case newd: SingleDenotation => newd
14881488
case newd =>
@@ -1573,7 +1573,7 @@ object Types {
15731573
TermRef.withSig(prefix, name.asTermName, sig)
15741574

15751575
protected def loadDenot(implicit ctx: Context): Denotation = {
1576-
val d = asMemberOf(prefix)
1576+
val d = asMemberOf(prefix, allowPrivate = true)
15771577
if (d.exists || ctx.phaseId == FirstPhaseId || !lastDenotation.isInstanceOf[SymDenotation])
15781578
d
15791579
else { // name has changed; try load in earlier phase and make current
@@ -1583,15 +1583,10 @@ object Types {
15831583
}
15841584
}
15851585

1586-
protected def asMemberOf(prefix: Type)(implicit ctx: Context): Denotation =
1586+
protected def asMemberOf(prefix: Type, allowPrivate: Boolean)(implicit ctx: Context): Denotation =
15871587
if (name.isShadowedName) prefix.nonPrivateMember(name.revertShadowed)
1588-
else lastDenotation match {
1589-
case d: SymDenotation if !d.is(Private) =>
1590-
// We shouldn't go from a non-private denotation to a private one
1591-
prefix.nonPrivateMember(name)
1592-
case _ =>
1593-
prefix.member(name)
1594-
}
1588+
else if (!allowPrivate) prefix.nonPrivateMember(name)
1589+
else prefix.member(name)
15951590

15961591
/** (1) Reduce a type-ref `W # X` or `W { ... } # U`, where `W` is a wildcard type
15971592
* to an (unbounded) wildcard type.
@@ -1791,7 +1786,7 @@ object Types {
17911786
val candidate = TermRef.withSig(prefix, name, sig)
17921787
if (symbol.exists && !candidate.symbol.exists) { // recompute from previous symbol
17931788
val ownSym = symbol
1794-
val newd = asMemberOf(prefix)
1789+
val newd = asMemberOf(prefix, allowPrivate = ownSym.is(Private))
17951790
candidate.withDenot(newd.suchThat(_.signature == ownSym.signature))
17961791
}
17971792
else candidate

0 commit comments

Comments
 (0)