aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
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
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')
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala5
-rw-r--r--src/dotty/tools/dotc/core/Flags.scala3
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala10
3 files changed, 15 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index e52809bd2..e21ec609d 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -288,9 +288,10 @@ object desugar {
}
else Nil
+ val selfType = if (self.tpt.isEmpty) classTypeRef else self.tpt
val self1 =
- if (self.isEmpty || !self.tpt.isEmpty) self
- else cpy.ValDef(self, self.mods, self.name, classTypeRef, self.rhs)
+ if (self.isEmpty) self
+ else cpy.ValDef(self, self.mods | SelfName, self.name, selfType, self.rhs)
val cdef1 = cpy.TypeDef(cdef, mods, name,
cpy.Template(impl, constr, parents1, self1,
diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala
index 7c25e471a..5fe146800 100644
--- a/src/dotty/tools/dotc/core/Flags.scala
+++ b/src/dotty/tools/dotc/core/Flags.scala
@@ -359,6 +359,9 @@ object Flags {
/** Symbol is a generated specialized member */
final val Specialized = commonFlag(53, "<specialized>")
+ /** Symbol is a self name */
+ final val SelfName = termFlag(54, "<selfname>")
+
/** Symbol is an implementation class */
final val ImplClass = typeFlag(54, "<implclass>")
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)