aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-04-01 11:58:25 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-11 09:33:12 +0200
commitb2bd0bf7d3df3b4c418e411290c2a2b18321aabf (patch)
tree8f03f697ed20c90ddf4dec37d476af1251cf6f3d
parent9f7012e886aa13f22e6ffc417050f9f6fc5b8003 (diff)
downloaddotty-b2bd0bf7d3df3b4c418e411290c2a2b18321aabf.tar.gz
dotty-b2bd0bf7d3df3b4c418e411290c2a2b18321aabf.tar.bz2
dotty-b2bd0bf7d3df3b4c418e411290c2a2b18321aabf.zip
Don't unmangle names in ClassfileParser
Classfile parsing is about JVM-level names, not Scala level ones. So it is more consistent to use mangled names throughout.
-rw-r--r--compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala25
1 files changed, 12 insertions, 13 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
index 98ac52533..13934f237 100644
--- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
+++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
@@ -247,22 +247,21 @@ class ClassfileParser(
final def objToAny(tp: Type)(implicit ctx: Context) =
if (tp.isDirectRef(defn.ObjectClass) && !ctx.phase.erasedTypes) defn.AnyType else tp
- private def sigToType(signature: TermName, owner: Symbol = null)(implicit ctx: Context): Type = {
- val sig = signature.toSimpleName
+ private def sigToType(sig: SimpleTermName, owner: Symbol = null)(implicit ctx: Context): Type = {
var index = 0
val end = sig.length
def accept(ch: Char): Unit = {
assert(sig(index) == ch, (sig(index), ch))
index += 1
}
- def subName(isDelimiter: Char => Boolean): TermName = {
+ def subName(isDelimiter: Char => Boolean): SimpleTermName = {
val start = index
while (!isDelimiter(sig(index))) { index += 1 }
- sig.slice(start, index).asTermName
+ sig.slice(start, index)
}
// Warning: sigToType contains nested completers which might be forced in a later run!
// So local methods need their own ctx parameters.
- def sig2type(tparams: immutable.Map[Name,Symbol], skiptvs: Boolean)(implicit ctx: Context): Type = {
+ def sig2type(tparams: immutable.Map[Name, Symbol], skiptvs: Boolean)(implicit ctx: Context): Type = {
val tag = sig(index); index += 1
(tag: @switch) match {
case BYTE_TAG => defn.ByteType
@@ -895,7 +894,7 @@ class ClassfileParser(
private val len = in.nextChar
private val starts = new Array[Int](len)
private val values = new Array[AnyRef](len)
- private val internalized = new Array[TermName](len)
+ private val internalized = new Array[SimpleTermName](len)
{ var i = 1
while (i < starts.length) {
@@ -922,12 +921,12 @@ class ClassfileParser(
}
/** Return the name found at given index. */
- def getName(index: Int): TermName = {
+ def getName(index: Int): SimpleTermName = {
if (index <= 0 || len <= index)
errorBadIndex(index)
values(index) match {
- case name: TermName => name
+ case name: SimpleTermName => name
case null =>
val start = starts(index)
if (in.buf(start).toInt != CONSTANT_UTF8) errorBadTag(start)
@@ -938,12 +937,12 @@ class ClassfileParser(
}
/** Return the name found at given index in the constant pool, with '/' replaced by '.'. */
- def getExternalName(index: Int): TermName = {
+ def getExternalName(index: Int): SimpleTermName = {
if (index <= 0 || len <= index)
errorBadIndex(index)
if (internalized(index) == null)
- internalized(index) = getName(index).replace('/', '.').unmangleClassName
+ internalized(index) = getName(index).replace('/', '.')
internalized(index)
}
@@ -955,9 +954,9 @@ class ClassfileParser(
val start = starts(index)
if (in.buf(start).toInt != CONSTANT_CLASS) errorBadTag(start)
val name = getExternalName(in.getChar(start + 1))
- if (name.is(ModuleClassName) && (name ne nme.nothingRuntimeClass) && (name ne nme.nullRuntimeClass))
+ if (name.endsWith("$") && (name ne nme.nothingRuntimeClass) && (name ne nme.nullRuntimeClass))
// Null$ and Nothing$ ARE classes
- c = ctx.requiredModule(name.sourceModuleName)
+ c = ctx.requiredModule(name.dropRight(1))
else c = classNameToSymbol(name)
values(index) = c
}
@@ -967,7 +966,7 @@ class ClassfileParser(
/** Return the external name of the class info structure found at 'index'.
* Use 'getClassSymbol' if the class is sure to be a top-level class.
*/
- def getClassName(index: Int): TermName = {
+ def getClassName(index: Int): SimpleTermName = {
val start = starts(index)
if (in.buf(start).toInt != CONSTANT_CLASS) errorBadTag(start)
getExternalName(in.getChar(start + 1))