aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Names.scala
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2015-08-04 11:18:41 -0700
committerodersky <odersky@gmail.com>2015-08-04 11:18:41 -0700
commit07e24e8640acf19a6bcedd1b68acbd7c8d8bf29b (patch)
treecc81897dd66a0353587ff83e297bfff3bac7c7d5 /src/dotty/tools/dotc/core/Names.scala
parent056e1246c9dc365bd37627923b999a80a57ca0f9 (diff)
parentd5280358d12c43c3268653c95c7edf3dcc7d60bf (diff)
downloaddotty-07e24e8640acf19a6bcedd1b68acbd7c8d8bf29b.tar.gz
dotty-07e24e8640acf19a6bcedd1b68acbd7c8d8bf29b.tar.bz2
dotty-07e24e8640acf19a6bcedd1b68acbd7c8d8bf29b.zip
Merge pull request #735 from dotty-staging/ycheck-methods
Ycheck that methods defined in ClassInfo exist in tree.
Diffstat (limited to 'src/dotty/tools/dotc/core/Names.scala')
-rw-r--r--src/dotty/tools/dotc/core/Names.scala21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/Names.scala b/src/dotty/tools/dotc/core/Names.scala
index 3ff10598d..12def1076 100644
--- a/src/dotty/tools/dotc/core/Names.scala
+++ b/src/dotty/tools/dotc/core/Names.scala
@@ -348,4 +348,25 @@ object Names {
StringBuilder.newBuilder.mapResult(s => from.fromChars(s.toCharArray, 0, s.length))
def apply(): Builder[Char, Name] = termNameBuilder
}
+
+ implicit val NameOrdering: Ordering[Name] = new Ordering[Name] {
+ def compare(x: Name, y: Name): Int = {
+ if (x.isTermName && y.isTypeName) 1
+ else if (x.isTypeName && y.isTermName) -1
+ else if (x eq y) 0
+ else {
+ val until = x.length min y.length
+ var i = 0
+
+ while (i < until && x(i) == y(i)) i = i + 1
+
+ if (i < until) {
+ if (x(i) < y(i)) -1
+ else /*(x(i) > y(i))*/ 1
+ } else {
+ x.length - y.length
+ }
+ }
+ }
+ }
}