diff options
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Flags.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 10 |
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) |