Skip to content

Commit 73ee8b4

Browse files
committed
Partial revert of previous commit.
Instead of avoiding fully qualified names, use a different separator in zincMangledName.
1 parent 157ed43 commit 73ee8b4

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ class ExtractAPI extends Phase {
7979
val pw = new PrintWriter(File(sourceFile.file.jpath).changeExtension("inc").toFile
8080
.bufferedWriter(append = true), true)
8181
try {
82+
pw.println()
83+
pw.println("API:")
84+
pw.println("====")
8285
classes.foreach(source => pw.println(DefaultShowAPI(source)))
8386
} finally pw.close()
8487
}

compiler/src/dotty/tools/dotc/sbt/package.scala

+14-7
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@ import dotty.tools.dotc.core.Contexts.Context
44
import dotty.tools.dotc.core.Symbols.Symbol
55
import dotty.tools.dotc.core.NameOps.stripModuleClassSuffix
66
import dotty.tools.dotc.core.Names.Name
7+
import dotty.tools.dotc.core.Names.termName
8+
import dotty.tools.dotc.core.NameKinds.QualifiedNameKind
79

810
inline val TermNameHash = 1987 // 300th prime
911
inline val TypeNameHash = 1993 // 301st prime
1012
inline val InlineParamHash = 1997 // 302nd prime
1113

1214
extension (sym: Symbol)
1315

14-
def constructorName(using Context) =
15-
sym.owner.name ++ ";init;"
16-
17-
/** Mangle a JVM symbol name in a format better suited for internal uses by sbt. */
18-
def zincMangledName(using Context): Name =
19-
if (sym.isConstructor) constructorName
20-
else sym.name.stripModuleClassSuffix
16+
/** Mangle a JVM symbol name in a format better suited for internal uses by sbt.
17+
* WARNING: output must not be written to TASTy, as it is not a valid TASTy name.
18+
*/
19+
private[sbt] def zincMangledName(using Context): Name =
20+
if sym.isConstructor then
21+
// TODO: ideally we should avoid unnecessarily caching these Zinc specific
22+
// names in the global chars array. But we would need to restructure
23+
// ExtractDependencies caches to avoid expensive `toString` on
24+
// each member reference.
25+
termName(sym.owner.fullName.mangledString.replace(".", ";").nn ++ ";init;")
26+
else
27+
sym.name.stripModuleClassSuffix

sbt-bridge/test/xsbt/ExtractUsedNamesSpecification.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class ExtractUsedNamesSpecification {
306306
// All classes extend Object
307307
"Object",
308308
// All classes have a default constructor called <init>
309-
"Object;init;",
309+
"java;lang;Object;init;",
310310
// the return type of the default constructor is Unit
311311
"Unit"
312312
)

0 commit comments

Comments
 (0)