Skip to content

Commit 021ddd3

Browse files
committed
Change visibility of some NamedType operations
- make private where possible - make public where the operation is immutable and has a simple to understand meaning.
1 parent 657fc86 commit 021ddd3

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ object SymDenotations {
415415
if (isType) fn.toTypeName else fn.toTermName
416416
}
417417

418-
419418
/** The encoded flat name of this denotation, where joined names are separated by `separator` characters. */
420419
def flatName(implicit ctx: Context): Name = fullNameSeparated(FlatName)
421420

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ object Types {
15951595
* Assumes that symbols do not change between periods in the same run.
15961596
* Used to get the class underlying a ThisType.
15971597
*/
1598-
final private[Types] def stableInRunSymbol(implicit ctx: Context): Symbol = {
1598+
private[Types] def stableInRunSymbol(implicit ctx: Context): Symbol = {
15991599
if (checkedPeriod.runId == ctx.runId) lastSymbol
16001600
else symbol
16011601
}
@@ -1689,10 +1689,10 @@ object Types {
16891689
d
16901690
}
16911691

1692-
def reloadDenot()(implicit ctx: Context) = // ### combine with invalidate(?)
1692+
def reloadDenot()(implicit ctx: Context) =
16931693
setDenot(loadDenot(name, allowPrivate = !symbol.exists || symbol.is(Private)))
16941694

1695-
protected def memberDenot(prefix: Type, name: Name, allowPrivate: Boolean)(implicit ctx: Context): Denotation =
1695+
private def memberDenot(prefix: Type, name: Name, allowPrivate: Boolean)(implicit ctx: Context): Denotation =
16961696
if (allowPrivate) prefix.member(name) else prefix.nonPrivateMember(name)
16971697

16981698
private def disambiguate(d: Denotation)(implicit ctx: Context): Denotation = {
@@ -1710,7 +1710,7 @@ object Types {
17101710
else d
17111711
}
17121712

1713-
private def setDenot(denot: Denotation)(implicit ctx: Context): Unit = { // ### make private? (also others)
1713+
private def setDenot(denot: Denotation)(implicit ctx: Context): Unit = {
17141714
if (ctx.isAfterTyper)
17151715
assert(!denot.isOverloaded, this)
17161716
if (Config.checkNoDoubleBindings)
@@ -1759,8 +1759,10 @@ object Types {
17591759
|period = ${ctx.phase} at run ${ctx.runId}""")
17601760
}
17611761

1762-
// ### make private or add comment
1763-
def infoDependsOnPrefix(symd: SymDenotation, prefix: Type)(implicit ctx: Context): Boolean =
1762+
/** A reference with the initial symbol in `symd` has an info that
1763+
* might depend on the given prefix.
1764+
*/
1765+
private def infoDependsOnPrefix(symd: SymDenotation, prefix: Type)(implicit ctx: Context): Boolean =
17641766
symd.maybeOwner.membersNeedAsSeenFrom(prefix) && !symd.is(NonMember)
17651767

17661768
/** Is this a reference to a class or object member? */
@@ -1889,11 +1891,11 @@ object Types {
18891891
case _ => withPrefix(prefix)
18901892
}
18911893

1892-
private[dotc] final def withSym(sym: Symbol)(implicit ctx: Context): ThisType =
1894+
final def withSym(sym: Symbol)(implicit ctx: Context): ThisType =
18931895
if ((designator ne sym) && sym.exists) NamedType(prefix, sym).asInstanceOf[ThisType]
18941896
else this
18951897

1896-
private[dotc] final def withDenot(denot: Denotation)(implicit ctx: Context): ThisType =
1898+
final def withDenot(denot: Denotation)(implicit ctx: Context): ThisType =
18971899
if (denot.exists) {
18981900
val adapted = withSym(denot.symbol)
18991901
if (adapted ne this) adapted.withDenot(denot).asInstanceOf[ThisType]
@@ -3352,14 +3354,9 @@ object Types {
33523354

33533355
def appliedRef(implicit ctx: Context): Type = {
33543356
def clsDenot = if (prefix eq cls.owner.thisType) cls.denot else cls.denot.copySymDenotation(info = this)
3355-
if (appliedRefCache == null) {
3356-
val tref =
3357-
if ((cls is PackageClass) || cls.owner.isTerm)
3358-
TypeRef(prefix, cls) // ### not always symbolicRef?
3359-
else TypeRef(prefix, cls.name, clsDenot)
3357+
if (appliedRefCache == null)
33603358
appliedRefCache =
3361-
tref.appliedTo(cls.typeParams.map(_.typeRef))
3362-
}
3359+
TypeRef(prefix, cls.name, clsDenot).appliedTo(cls.typeParams.map(_.typeRef))
33633360
appliedRefCache
33643361
}
33653362

0 commit comments

Comments
 (0)