Skip to content

Commit 7c71b08

Browse files
committed
[TO BE REVERTED] Gross hack to work around leaky NameHelper abstraction
1 parent b537890 commit 7c71b08

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ class GenBCode extends Phase {
5252
new PlainDirectory(new Directory(new JFile(ctx.settings.d.value)))
5353

5454
def run(implicit ctx: Context): Unit = {
55-
new GenBCodePipeline(entryPoints.toList,
56-
new DottyBackendInterface(outputDir, superCallsMap.toMap)(ctx))(ctx).run(ctx.compilationUnit.tpdTree)
55+
val saved = Names.useMangled
56+
Names.useMangled = true
57+
try new GenBCodePipeline(entryPoints.toList,
58+
new DottyBackendInterface(outputDir, superCallsMap.toMap)(ctx))(ctx).run(ctx.compilationUnit.tpdTree)
59+
finally Names.useMangled = saved
5760
entryPoints.clear()
5861
}
5962
}

compiler/src/dotty/tools/dotc/core/Names.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ import java.util.HashMap
2222
object Names {
2323
import NameKinds._
2424

25+
// Gross hack because the backend uses toString on arbitrary names, which means
26+
// that the NameHelper abstraction is leaky. As long as cannot get rid of this,
27+
// parallel compilation is impossible.
28+
@sharable var useMangled: Boolean = false
29+
2530
/** A common class for things that can be turned into names.
2631
* Instances are both names and strings, the latter via a decorator.
2732
*/
@@ -295,7 +300,11 @@ object Names {
295300
override def hashCode: Int = start
296301

297302
override def toString =
298-
if (length == 0) "" else new String(chrs, start, length)
303+
if (length == 0) ""
304+
else {
305+
val n = if (useMangled) mangled.asSimpleName else this
306+
new String(chrs, n.start, n.length)
307+
}
299308

300309
def sliceToString(from: Int, end: Int) =
301310
if (end <= from) "" else new String(chrs, start + from, end - from)

0 commit comments

Comments
 (0)