Skip to content

Commit 2c4ac2c

Browse files
committed
[TO BE REVERTED] Gross hack to work around leaky NameHelper abstraction
1 parent 4641bf2 commit 2c4ac2c

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
@@ -50,8 +50,11 @@ class GenBCode extends Phase {
5050
new PlainDirectory(new Directory(new JFile(ctx.settings.d.value)))
5151

5252
def run(implicit ctx: Context): Unit = {
53-
new GenBCodePipeline(entryPoints.toList,
54-
new DottyBackendInterface(outputDir, superCallsMap.toMap)(ctx))(ctx).run(ctx.compilationUnit.tpdTree)
53+
val saved = Names.useMangled
54+
Names.useMangled = true
55+
try new GenBCodePipeline(entryPoints.toList,
56+
new DottyBackendInterface(outputDir, superCallsMap.toMap)(ctx))(ctx).run(ctx.compilationUnit.tpdTree)
57+
finally Names.useMangled = saved
5558
entryPoints.clear()
5659
}
5760
}

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

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

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

289294
override def toString =
290-
if (length == 0) "" else new String(chrs, start, length)
295+
if (length == 0) ""
296+
else {
297+
val n = if (useMangled) mangled.asSimpleName else this
298+
new String(chrs, n.start, n.length)
299+
}
291300

292301
def debugString: String = toString
293302
}

0 commit comments

Comments
 (0)