Skip to content

Commit e12bc65

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

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ object NameTags extends TastyFormat.NameTags {
4040
inline val EXPLICITFIELD = 38 // An explicitly named field, introduce to avoid a clash
4141
// with a regular field of the underlying name
4242

43+
inline val ZINCMANGLED = 39 // a reserved tag for use in Zinc name mangling (replace `.` by `::`)
44+
4345
def nameTagToString(tag: Int): String = tag match {
4446
case UTF8 => "UTF8"
4547
case QUALIFIED => "QUALIFIED"
@@ -61,6 +63,7 @@ object NameTags extends TastyFormat.NameTags {
6163
case PARAMACC => "PARAMACC"
6264
case ADAPTEDCLOSURE => "ADAPTEDCLOSURE"
6365
case OBJECTCLASS => "OBJECTCLASS"
66+
case ZINCMANGLED => "ZINCMANGLED"
6467

6568
case SIGNED => "SIGNED"
6669
case TARGETSIGNED => "TARGETSIGNED"

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

+12-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ 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.NameKinds.QualifiedNameKind
8+
import dotty.tools.dotc.core.NameTags.ZINCMANGLED
79

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

12-
extension (sym: Symbol)
14+
private inline val ZINC_MANGLED_SEPARATOR = "::"
15+
16+
/** Expanded names of the form `prefix :: name`. These only occur in zinc phases, and should not be written to TASTy */
17+
private[sbt] val ZincMangledName: QualifiedNameKind = new QualifiedNameKind(ZINCMANGLED, ZINC_MANGLED_SEPARATOR)
1318

14-
def constructorName(using Context) =
15-
sym.owner.name ++ ";init;"
19+
extension (sym: Symbol)
1620

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
21+
/** Mangle a JVM symbol name in a format better suited for internal uses by sbt.
22+
* WARNING: output must not be written to TASTy, as it is not a valid TASTy name.
23+
*/
24+
private[sbt] def zincMangledName(using Context): Name =
25+
if (sym.isConstructor) sym.owner.fullNameSeparated(ZincMangledName) ++ ";init;"
2026
else 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)