aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-12-17 17:19:04 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-12-17 17:42:01 +0100
commit0a6461812aa5803726a8607546668f624987b140 (patch)
tree85c09e7626752bcc7938524a44c66cec536c97af /src
parent6eaf815923e194cd4d0da8faa0f132dbf8de4608 (diff)
downloaddotty-0a6461812aa5803726a8607546668f624987b140.tar.gz
dotty-0a6461812aa5803726a8607546668f624987b140.tar.bz2
dotty-0a6461812aa5803726a8607546668f624987b140.zip
Simplified and commented makePackageObjPrefixExplicit
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/TypeErasure.scala2
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala9
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala2
3 files changed, 9 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/TypeErasure.scala b/src/dotty/tools/dotc/TypeErasure.scala
index 9f9894c57..a9ae34213 100644
--- a/src/dotty/tools/dotc/TypeErasure.scala
+++ b/src/dotty/tools/dotc/TypeErasure.scala
@@ -108,7 +108,7 @@ object TypeErasure {
def erasedRef(tp: Type)(implicit ctx: Context): Type = tp match {
case tp: TermRef =>
assert(tp.symbol.exists, tp)
- val tp1 = ctx.makePackageObjPrefixExplicit(tp, tp.symbol)
+ val tp1 = ctx.makePackageObjPrefixExplicit(tp)
if (tp1 ne tp) erasedRef(tp1)
else TermRef(erasedRef(tp.prefix), tp.symbol.asTerm)
case tp: ThisType =>
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index 4716d89b7..260e2f6d6 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -224,9 +224,14 @@ trait TypeOps { this: Context =>
cls.enter(sym, decls)
}
- def makePackageObjPrefixExplicit(tpe: NamedType, d: Denotation): Type = {
+ /** If `tpe` is of the form `p.x` where `p` refers to a package
+ * but `x` is not owned by a package, expand it to
+ *
+ * p.package.x
+ */
+ def makePackageObjPrefixExplicit(tpe: NamedType): Type = {
def tryInsert(pkgClass: SymDenotation): Type = pkgClass match {
- case pkgCls: PackageClassDenotation if !(d.symbol.maybeOwner is Package) =>
+ case pkgCls: PackageClassDenotation if !(tpe.symbol.maybeOwner is Package) =>
tpe.derivedSelect(pkgCls.packageObj.valRef)
case _ =>
tpe
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index 4394b8557..46aa2e953 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -144,7 +144,7 @@ trait TypeAssigner {
else if (d.symbol is TypeParamAccessor) // always dereference type param accessors
ensureAccessible(d.info.bounds.hi, superAccess, pos)
else
- ctx.makePackageObjPrefixExplicit(tpe withDenot d, d)
+ ctx.makePackageObjPrefixExplicit(tpe withDenot d)
case _ =>
tpe
}