diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-26 14:53:42 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-26 14:53:42 +0200 |
commit | 08c6eacaf59386ed26aeead472e1df2c5944a3fb (patch) | |
tree | dff3e1c4ae4d1f1b62e4e3509231f9a5f16024ed /src/dotty/tools/dotc/ast/Trees.scala | |
parent | 97d89afc4769c4badb42284c9b5d97b663f870f6 (diff) | |
download | dotty-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/ast/Trees.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/Trees.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala index 8d243a0cb..554517cd7 100644 --- a/src/dotty/tools/dotc/ast/Trees.scala +++ b/src/dotty/tools/dotc/ast/Trees.scala @@ -469,6 +469,15 @@ object Trees { case class This[-T >: Untyped] private[ast] (qual: TypeName) extends DenotingTree[T] with TermTree[T] { type ThisTree[-T >: Untyped] = This[T] + // Denotation of a This tree is always the udnerlying class; needs correction for modules. + override def denot(implicit ctx: Context): Denotation = { + tpe match { + case tpe @ TermRef(pre, _) if tpe.symbol is Module => + tpe.symbol.moduleClass.denot.asSeenFrom(pre) + case _ => + super.denot + } + } } /** C.super[mix], where qual = C.this */ |