aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-08-26 14:53:42 +0200
committerMartin Odersky <odersky@gmail.com>2014-08-26 14:53:42 +0200
commit08c6eacaf59386ed26aeead472e1df2c5944a3fb (patch)
treedff3e1c4ae4d1f1b62e4e3509231f9a5f16024ed /src/dotty/tools/dotc/core/SymDenotations.scala
parent97d89afc4769c4badb42284c9b5d97b663f870f6 (diff)
downloaddotty-08c6eacaf59386ed26aeead472e1df2c5944a3fb.tar.gz
dotty-08c6eacaf59386ed26aeead472e1df2c5944a3fb.tar.bz2
dotty-08c6eacaf59386ed26aeead472e1df2c5944a3fb.zip
thisType of a module class is a term ref to the source module.
Module classes now always get the sourceModule term ref as their this type. We would like to eliminate ThisType() of a module class completely, as this hangs on to a symbol which might become stale for globally accessible modules. This commit is the first step. It contains the change to thisType and the necessary fixes to make the test suite pass.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 63ce7f756..a3828552d 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -467,14 +467,17 @@ object SymDenotations {
(linked ne NoSymbol) && accessWithin(linked)
}
- /** Is `pre` of the form C.this, where C is exactly the owner of this symbol,
+ /** Is `pre` the same as C.thisThis, where C is exactly the owner of this symbol,
* or, if this symbol is protected, a subclass of the owner?
*/
def isCorrectThisType(pre: Type): Boolean = pre match {
case ThisType(pclazz) =>
(pclazz eq owner) ||
(this is Protected) && pclazz.derivesFrom(owner)
- case _ => false
+ case pre: TermRef =>
+ pre.symbol.moduleClass == owner
+ case _ =>
+ false
}
/** Is protected access to target symbol permitted? */
@@ -1002,11 +1005,13 @@ object SymDenotations {
myThisType
}
- private def computeThisType(implicit ctx: Context): Type = ThisType(classSymbol) /*
- if ((this is PackageClass) && !isRoot)
- TermRef(owner.thisType, name.toTermName)
- else
- ThisType(classSymbol) */
+ private def computeThisType(implicit ctx: Context): Type =
+ if (this.is(Module, butNot = Package)) {
+ val pre = owner.thisType
+ if ((pre eq NoPrefix) || ctx.erasedTypes) pre select sourceModule
+ else TermRef.withSig(pre, name.sourceModuleName, Signature.NotAMethod)
+ }
+ else ThisType(classSymbol)
private[this] var myTypeRef: TypeRef = null