diff options
author | Martin Odersky <odersky@gmail.com> | 2017-03-27 21:55:26 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-11 09:33:11 +0200 |
commit | 0021ffb0f1a0a857b7cdc8cdf769ae727dcb4b2c (patch) | |
tree | 89499a1172e48e81a86d61242090819d658c5aa7 /compiler/src/dotty/tools/dotc/core/Names.scala | |
parent | 1d6f5f7f33f9e4be29553cb7ef1e6f054a64dc6b (diff) | |
download | dotty-0021ffb0f1a0a857b7cdc8cdf769ae727dcb4b2c.tar.gz dotty-0021ffb0f1a0a857b7cdc8cdf769ae727dcb4b2c.tar.bz2 dotty-0021ffb0f1a0a857b7cdc8cdf769ae727dcb4b2c.zip |
Add ShadowedName and AvoidClashName
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/Names.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Names.scala | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Names.scala b/compiler/src/dotty/tools/dotc/core/Names.scala index 4524f2061..d1788b6f9 100644 --- a/compiler/src/dotty/tools/dotc/core/Names.scala +++ b/compiler/src/dotty/tools/dotc/core/Names.scala @@ -167,13 +167,16 @@ object Names { } } + private def rewrap(underlying: TermName) = + if (underlying eq this.underlying) this else underlying.add(info) + /** Return derived name with given `info` and the current * name as underlying name. */ def derived(info: NameInfo): TermName = { val ownTag = this.info.tag if (ownTag < info.tag || definesNewName(info.tag)) add(info) - else if (ownTag > info.tag) underlying.derived(info).add(this.info) + else if (ownTag > info.tag) rewrap(underlying.derived(info)) else { assert(info == this.info) this @@ -183,7 +186,7 @@ object Names { def exclude(kind: NameExtractor): TermName = { val ownTag = this.info.tag if (ownTag < kind.tag || definesNewName(ownTag)) this - else if (ownTag > kind.tag) underlying.exclude(kind).add(this.info) + else if (ownTag > kind.tag) rewrap(underlying.exclude(kind)) else underlying } @@ -202,9 +205,6 @@ object Names { def apply(n: Int) = chrs(start + n) - //override def derived(info: NameInfo): TermName = add(info) - //override def is(kind: NameExtractor) = false - private def contains(ch: Char): Boolean = { var i = 0 while (i < length && chrs(start + i) != ch) i += 1 |