diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-27 10:48:16 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-27 10:55:47 +0200 |
commit | bfb328ff64dcfa103c91dd0cd55a617e370d6ef3 (patch) | |
tree | b7003776657a486c8fbfac43a7812b10555b0d5a /src/dotty/tools/dotc/core/SymDenotations.scala | |
parent | 292ce6844a212b47defc671c91396d7cec86833b (diff) | |
download | dotty-bfb328ff64dcfa103c91dd0cd55a617e370d6ef3.tar.gz dotty-bfb328ff64dcfa103c91dd0cd55a617e370d6ef3.tar.bz2 dotty-bfb328ff64dcfa103c91dd0cd55a617e370d6ef3.zip |
Make ThisTypes take TypeRefs instead of ClassSymbols
This avoids stale symbol errors and does not need the somewhat
unsystematic symbol rebinding of the last commit.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index cb457bd73..660287089 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -471,9 +471,8 @@ object SymDenotations { * 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 pre: ThisType => + (pre.cls eq owner) || (this is Protected) && pre.cls.derivesFrom(owner) case pre: TermRef => pre.symbol.moduleClass == owner case _ => @@ -1000,18 +999,26 @@ object SymDenotations { private[this] var myThisType: Type = null + /** The this-type depends on the kind of class: + * - for a package class `p`: ThisType(TypeRef(Noprefix, p)) + * - for a module class `m`: A term ref to m's source module. + * - for all other classes `c` with owner `o`: ThisType(TypeRef(o.thisType, c)) + */ override def thisType(implicit ctx: Context): Type = { if (myThisType == null) myThisType = computeThisType myThisType } private def computeThisType(implicit ctx: Context): Type = - if (this.is(Module, butNot = Package)) { + if (this is Package) + ThisType.raw(TypeRef(NoPrefix, symbol.asType)) + else { val pre = owner.thisType - if ((pre eq NoPrefix) || ctx.erasedTypes) pre select sourceModule - else TermRef.withSig(pre, name.sourceModuleName, Signature.NotAMethod) + if (this is Module) + if (isMissing(pre)) TermRef(pre, sourceModule.asTerm) + else TermRef.withSig(pre, name.sourceModuleName, Signature.NotAMethod) + else ThisType.raw(TypeRef(pre, symbol.asType)) } - else ThisType.raw(classSymbol) private[this] var myTypeRef: TypeRef = null |