diff options
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 |