diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-10-03 09:18:41 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-10-03 15:47:44 +0200 |
commit | b090f9748fff915df82f2a4908e7075f5cf1c91c (patch) | |
tree | 4fa73d26b8a3dad8dcf6b36e0bf7e37c83be2ca5 /src/reflect | |
parent | 8aae23ed47c4e38a465ff3373392484ca82473d1 (diff) | |
download | scala-b090f9748fff915df82f2a4908e7075f5cf1c91c.tar.gz scala-b090f9748fff915df82f2a4908e7075f5cf1c91c.tar.bz2 scala-b090f9748fff915df82f2a4908e7075f5cf1c91c.zip |
Rework cff8b569 to heal the windows build.
- change newTermName to fix negative length names
rather than reject them
- restore the old logic in unspecializedName for names that
result from AnyRef specialized type parameters.
Why does fix the windows build? I remain none the wiser.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Names.scala | 6 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/StdNames.scala | 30 |
2 files changed, 17 insertions, 19 deletions
diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala index f998d95349..4075653674 100644 --- a/src/reflect/scala/reflect/internal/Names.scala +++ b/src/reflect/scala/reflect/internal/Names.scala @@ -87,11 +87,13 @@ trait Names extends api.Names { * TODO - have a mode where name validation is performed at creation time * (e.g. if a name has the string "$class" in it, then fail if that * string is not at the very end.) + * + * @param len0 the length of the name. Negative lengths result in empty names. */ - final def newTermName(cs: Array[Char], offset: Int, len: Int, cachedString: String): TermName = { + final def newTermName(cs: Array[Char], offset: Int, len0: Int, cachedString: String): TermName = { def body = { require(offset >= 0, "offset must be non-negative, got " + offset) - require(len >= 0, "length must be non-negative, got " + len) + val len = math.max(len0, 0) val h = hashValue(cs, offset, len) & HASH_MASK var n = termHashtable(h) while ((n ne null) && (n.length != len || !equals(n.start, cs, offset, len))) diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index c1fd5b3cd6..21dbc462c5 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -409,11 +409,8 @@ trait StdNames { */ def unspecializedName(name: Name): Name = ( // DUPLICATED LOGIC WITH `splitSpecializedName` - if (name endsWith SPECIALIZED_SUFFIX) { - val idxM = name.lastIndexOf('m') - val to = (if (idxM > 0) idxM - 1 else name.length - SPECIALIZED_SUFFIX.length) - name.subName(0, to) - } + if (name endsWith SPECIALIZED_SUFFIX) + name.subName(0, name.lastIndexOf('m') - 1) else name ) @@ -428,19 +425,18 @@ trait StdNames { * * @return (unspecializedName, class tparam specializations, method tparam specializations) */ - def splitSpecializedName(name: Name): (Name, String, String) = { + def splitSpecializedName(name: Name): (Name, String, String) = // DUPLICATED LOGIC WITH `unspecializedName` - if (name endsWith SPECIALIZED_SUFFIX) { - val name1 = name dropRight SPECIALIZED_SUFFIX.length - val idxC = name1 lastIndexOf 'c' - val idxM = name1 lastIndexOf 'm' - if (idxC > idxM && idxM > 0) - (name1.subName(0, idxM - 1), name1.subName(idxC + 1, name1.length).toString, name1.subName(idxM + 1, idxC).toString) - else - (name.subName(0, name.length - SPECIALIZED_SUFFIX.length), "", "") - } - else (name, "", "") - } + if (name endsWith SPECIALIZED_SUFFIX) { + val name1 = name dropRight SPECIALIZED_SUFFIX.length + val idxC = name1 lastIndexOf 'c' + val idxM = name1 lastIndexOf 'm' + + (name1.subName(0, idxM - 1), + name1.subName(idxC + 1, name1.length).toString, + name1.subName(idxM + 1, idxC).toString) + } else + (name, "", "") // Nominally, name$default$N, encoded for <init> def defaultGetterName(name: Name, pos: Int): TermName = ( |