Skip to content

Commit f538d6f

Browse files
committed
Generate JVM-compatible names for doc artifacts
We used to put the position of the doc artifact symbols inside their names, which created a name that is not JVM-compatible. This commit uses the fresh name creators to generate a fresh name for every symbol introduced by the documentation. The name is a fresh name composed of the name of the symbol that owns the documentation, suffixed by `$doc`.
1 parent 23cea59 commit f538d6f

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ object Comments {
121121

122122
tree match {
123123
case tree: untpd.DefDef =>
124-
val newName = (tree.name.show + "$" + codePos + "$doc").toTermName
124+
val newName = ctx.freshNames.newName(tree.name, NameKinds.DocArtifactName)
125125
untpd.DefDef(newName, tree.tparams, tree.vparamss, tree.tpt, tree.rhs)
126126
case _ =>
127127
ctx.error(ProperDefinitionNotFound(), codePos)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ object NameKinds {
290290
val SkolemName = new UniqueNameKind("?")
291291
val LiftedTreeName = new UniqueNameKind("liftedTree")
292292
val SuperArgName = new UniqueNameKind("$superArg$")
293+
val DocArtifactName = new UniqueNameKind("$doc")
293294

294295
/** A kind of unique extension methods; Unlike other unique names, these can be
295296
* unmangled.

0 commit comments

Comments
 (0)