aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Names.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-05-24 16:37:47 +0200
committerMartin Odersky <odersky@gmail.com>2013-05-24 16:39:06 +0200
commitacc2b198692687394c9f8f84b16a0bec9ae12ee3 (patch)
treef9a9d588a629315aa82ddcee8c285d7614ed3201 /src/dotty/tools/dotc/core/Names.scala
parente1be722f469c45e7546388359b5870a07f4c14b8 (diff)
downloaddotty-acc2b198692687394c9f8f84b16a0bec9ae12ee3.tar.gz
dotty-acc2b198692687394c9f8f84b16a0bec9ae12ee3.tar.bz2
dotty-acc2b198692687394c9f8f84b16a0bec9ae12ee3.zip
NameTransformer.encode now goes from names to names.
Also, special treatment of <init>, which is not encoded.
Diffstat (limited to 'src/dotty/tools/dotc/core/Names.scala')
-rw-r--r--src/dotty/tools/dotc/core/Names.scala12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/Names.scala b/src/dotty/tools/dotc/core/Names.scala
index e5535cff3..8cc07d5b5 100644
--- a/src/dotty/tools/dotc/core/Names.scala
+++ b/src/dotty/tools/dotc/core/Names.scala
@@ -111,7 +111,8 @@ object Names {
else this
/** Replace operator symbols by corresponding \$op_name's. */
- def encode: Name = fromString(NameTransformer.encode(toString))
+ def encode: Name =
+ if (this eq CONSTRUCTOR) this else NameTransformer.encode(this)
/** A more efficient version of concatenation */
def ++ (other: Name): ThisName = ++ (other.toString)
@@ -371,15 +372,9 @@ object Names {
/** Create a term name from a string, without encoding operators */
def termName(s: String): TermName = termName(s.toCharArray, 0, s.length)
- /** Create a term name from a string, encode if necessary*/
- def encodedTermName(s: String): TermName = termName(NameTransformer.encode(s))
-
/** Create a type name from a string, wihtout encoding operators */
def typeName(s: String): TypeName = typeName(s.toCharArray, 0, s.length)
- /** Create a type name from a string, encode if necessary*/
- def encodedTypeName(s: String): TypeName = typeName(NameTransformer.encode(s))
-
/** The term name represented by the empoty string */
val EmptyTermName = new TermName(-1, 0, null)
@@ -388,6 +383,9 @@ object Names {
/** The type name represented by the empoty string */
val EmptyTypeName = EmptyTermName.toTypeName
+ // can't use nme.CONSTRUCTOR in encode because of bootstrap failures.
+ private val CONSTRUCTOR = termName("<init>")
+
def termNameBuilder: Builder[Char, TermName] =
StringBuilder.newBuilder.mapResult(termName)