aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-31 12:49:23 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-31 12:49:54 +0100
commite56b26b55de6459ae74ff86e2a62dd2d00436ab2 (patch)
tree2255d91ad0e309acf3df925dd329b9ea2feaabc3 /src/dotty/tools/dotc/typer/Typer.scala
parent3edab6ec1444b19203381612fba3e16ca1bafc95 (diff)
downloaddotty-e56b26b55de6459ae74ff86e2a62dd2d00436ab2.tar.gz
dotty-e56b26b55de6459ae74ff86e2a62dd2d00436ab2.tar.bz2
dotty-e56b26b55de6459ae74ff86e2a62dd2d00436ab2.zip
Fixing the type of a named self reference.
This was previously C.this.self but it should be C.this
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index be84d1bea..bb1d4dce1 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -283,6 +283,12 @@ class Typer extends Namer with Applications with Implicits {
case denot: SingleDenotation => denot.symbol.sourceFile == ctx.source
}
+ /** Is `denot` the denotation of a self symbol? */
+ def isSelfDenot(denot: Denotation) = denot match {
+ case denot: SymDenotation => denot is SelfName
+ case _ => false
+ }
+
// begin findRef
if (ctx.scope == null) previous
else {
@@ -291,7 +297,9 @@ class Typer extends Namer with Applications with Implicits {
val defDenot = ctx.denotNamed(name)
if (qualifies(defDenot)) {
val curOwner = ctx.owner
- val found = curOwner.thisType.select(name, defDenot)
+ val found =
+ if (isSelfDenot(defDenot)) curOwner.thisType
+ else curOwner.thisType.select(name, defDenot)
if (!(curOwner is Package) || (defDenot.symbol is Package) || isDefinedInCurrentUnit(defDenot))
return checkNewOrShadowed(found, definition) // no need to go further out, we found highest prec entry
else if (prevPrec < packageClause)