aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index 8190b8cb6..260e2f6d6 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -2,7 +2,7 @@ package dotty.tools.dotc
package core
import Contexts._, Types._, Symbols._, Names._, Flags._, Scopes._
-import SymDenotations._
+import SymDenotations._, Denotations.Denotation
import config.Printers._
import Decorators._
import StdNames._
@@ -224,6 +224,25 @@ trait TypeOps { this: Context =>
cls.enter(sym, decls)
}
+ /** 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 !(tpe.symbol.maybeOwner is Package) =>
+ tpe.derivedSelect(pkgCls.packageObj.valRef)
+ case _ =>
+ tpe
+ }
+ tpe.prefix match {
+ case pre: ThisType if pre.cls is Package => tryInsert(pre.cls)
+ case pre: TermRef if pre.symbol is Package => tryInsert(pre.symbol.moduleClass)
+ case _ => tpe
+ }
+ }
+
/** If we have member definitions
*
* type argSym v= from