Skip to content

Commit 0a64618

Browse files
oderskyDarkDimius
authored andcommitted
Simplified and commented makePackageObjPrefixExplicit
1 parent 6eaf815 commit 0a64618

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/dotty/tools/dotc/TypeErasure.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ object TypeErasure {
108108
def erasedRef(tp: Type)(implicit ctx: Context): Type = tp match {
109109
case tp: TermRef =>
110110
assert(tp.symbol.exists, tp)
111-
val tp1 = ctx.makePackageObjPrefixExplicit(tp, tp.symbol)
111+
val tp1 = ctx.makePackageObjPrefixExplicit(tp)
112112
if (tp1 ne tp) erasedRef(tp1)
113113
else TermRef(erasedRef(tp.prefix), tp.symbol.asTerm)
114114
case tp: ThisType =>

src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,14 @@ trait TypeOps { this: Context =>
224224
cls.enter(sym, decls)
225225
}
226226

227-
def makePackageObjPrefixExplicit(tpe: NamedType, d: Denotation): Type = {
227+
/** If `tpe` is of the form `p.x` where `p` refers to a package
228+
* but `x` is not owned by a package, expand it to
229+
*
230+
* p.package.x
231+
*/
232+
def makePackageObjPrefixExplicit(tpe: NamedType): Type = {
228233
def tryInsert(pkgClass: SymDenotation): Type = pkgClass match {
229-
case pkgCls: PackageClassDenotation if !(d.symbol.maybeOwner is Package) =>
234+
case pkgCls: PackageClassDenotation if !(tpe.symbol.maybeOwner is Package) =>
230235
tpe.derivedSelect(pkgCls.packageObj.valRef)
231236
case _ =>
232237
tpe

src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ trait TypeAssigner {
144144
else if (d.symbol is TypeParamAccessor) // always dereference type param accessors
145145
ensureAccessible(d.info.bounds.hi, superAccess, pos)
146146
else
147-
ctx.makePackageObjPrefixExplicit(tpe withDenot d, d)
147+
ctx.makePackageObjPrefixExplicit(tpe withDenot d)
148148
case _ =>
149149
tpe
150150
}

0 commit comments

Comments
 (0)