diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-25 15:59:02 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-25 15:59:11 +0100 |
commit | a19237f7be972870ca1c7477704a724419ef793f (patch) | |
tree | 39cfaa05657e5e83de45c94725510f533cb015bf /src/dotty/tools | |
parent | 7260b2607a4b0249f63bb75dac6143e902b91c66 (diff) | |
download | dotty-a19237f7be972870ca1c7477704a724419ef793f.tar.gz dotty-a19237f7be972870ca1c7477704a724419ef793f.tar.bz2 dotty-a19237f7be972870ca1c7477704a724419ef793f.zip |
Making the name of self visible inside a class.
Previously, it wasn't.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 2baa3ea13..25006d72f 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -34,8 +34,14 @@ trait NamerContextOps { this: Context => /** The denotation with the given name in current context */ def denotNamed(name: Name): Denotation = if (owner.isClass) - if (outer.owner == owner) + if (outer.owner == owner) { // inner class scope; check whether we are referring to self + if (scope.size == 1) { + val elem = scope.asInstanceOf[MutableScope].lastEntry + if (elem.name == name) return elem.sym.denot // return self + } + assert(scope.size <= 1, scope) owner.thisType.member(name) + } else // we are in the outermost context belonging to a class; self is invisible here. See inClassContext. owner.findMember(name, owner.thisType, EmptyFlags) else |