Skip to content

Commit 5b49561

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 939d1e2 commit 5b49561

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ object Types {
16041604
* Assumes that symbols do not change between periods in the same run.
16051605
* Used to get the class underlying a ThisType.
16061606
*/
1607-
final private[Types] def stableInRunSymbol(implicit ctx: Context): Symbol = {
1607+
private[Types] def stableInRunSymbol(implicit ctx: Context): Symbol = {
16081608
if (checkedPeriod.runId == ctx.runId) lastSymbol
16091609
else symbol
16101610
}
@@ -1698,10 +1698,10 @@ object Types {
16981698
d
16991699
}
17001700

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

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

17071707
private def disambiguate(d: Denotation)(implicit ctx: Context): Denotation = {
@@ -1719,7 +1719,7 @@ object Types {
17191719
else d
17201720
}
17211721

1722-
private def setDenot(denot: Denotation)(implicit ctx: Context): Unit = { // ### make private? (also others)
1722+
private def setDenot(denot: Denotation)(implicit ctx: Context): Unit = {
17231723
if (ctx.isAfterTyper)
17241724
assert(!denot.isOverloaded, this)
17251725
if (Config.checkNoDoubleBindings)
@@ -1768,8 +1768,10 @@ object Types {
17681768
|period = ${ctx.phase} at run ${ctx.runId}""")
17691769
}
17701770

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

17751777
/** Is this a reference to a class or object member? */
@@ -1898,11 +1900,11 @@ object Types {
18981900
case _ => withPrefix(prefix)
18991901
}
19001902

1901-
private[dotc] final def withSym(sym: Symbol)(implicit ctx: Context): ThisType =
1903+
final def withSym(sym: Symbol)(implicit ctx: Context): ThisType =
19021904
if ((designator ne sym) && sym.exists) NamedType(prefix, sym).asInstanceOf[ThisType]
19031905
else this
19041906

1905-
private[dotc] final def withDenot(denot: Denotation)(implicit ctx: Context): ThisType =
1907+
final def withDenot(denot: Denotation)(implicit ctx: Context): ThisType =
19061908
if (denot.exists) {
19071909
val adapted = withSym(denot.symbol)
19081910
if (adapted ne this) adapted.withDenot(denot).asInstanceOf[ThisType]
@@ -3379,14 +3381,9 @@ object Types {
33793381

33803382
def appliedRef(implicit ctx: Context): Type = {
33813383
def clsDenot = if (prefix eq cls.owner.thisType) cls.denot else cls.denot.copySymDenotation(info = this)
3382-
if (appliedRefCache == null) {
3383-
val tref =
3384-
if ((cls is PackageClass) || cls.owner.isTerm)
3385-
TypeRef(prefix, cls) // ### not always symbolicRef?
3386-
else TypeRef(prefix, cls.name, clsDenot)
3384+
if (appliedRefCache == null)
33873385
appliedRefCache =
3388-
tref.appliedTo(cls.typeParams.map(_.typeRef))
3389-
}
3386+
TypeRef(prefix, cls.name, clsDenot).appliedTo(cls.typeParams.map(_.typeRef))
33903387
appliedRefCache
33913388
}
33923389

0 commit comments

Comments
 (0)