Skip to content

Commit c215592

Browse files
committed
Fix problem with names encoding in scalap.
The refactoring performed in 020053c made use of naming encoding more consisted but introduced a regression in scalap. The problem is that the old encoder that scalap had didn't escape any characters that were not included in its opcode list. `NameTransformer` performs full encoding so it also encodes dots that are being used as separators for packages. Therefore, in order to retain the old behaviour we need to split the name by dots before feeding each fragment to `NameTransformer`. Review by @paulp.
1 parent b9fd3f7 commit c215592

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/scalap/scala/tools/scalap/Main.scala

+8-3
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,14 @@ class Main {
9797
*/
9898
def process(args: Arguments, path: ClassPath[AbstractFile])(classname: String): Unit = {
9999
// find the classfile
100-
val encName = NameTransformer.encode(
101-
if (classname == "scala.AnyRef") "java.lang.Object"
102-
else classname)
100+
val encName = classname match {
101+
case "scala.AnyRef" => "java.lang.Object"
102+
case _ =>
103+
// we have to encode every fragment of a name separately, otherwise the NameTransformer
104+
// will encode using unicode escaping dot separators as well
105+
// we can afford allocations because this is not a performance critical code
106+
classname.split('.').map(NameTransformer.encode).mkString(".")
107+
}
103108
val cls = path.findClass(encName)
104109
if (cls.isDefined && cls.get.binary.isDefined) {
105110
val cfile = cls.get.binary.get

0 commit comments

Comments
 (0)