Skip to content

Commit

Permalink
Partial revert of previous commit.
Browse files Browse the repository at this point in the history
Instead of avoiding fully qualified names,
use a different separator in zincMangledName.
  • Loading branch information
bishabosha committed Mar 16, 2024
1 parent 157ed43 commit 73ee8b4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class ExtractAPI extends Phase {
val pw = new PrintWriter(File(sourceFile.file.jpath).changeExtension("inc").toFile
.bufferedWriter(append = true), true)
try {
pw.println()
pw.println("API:")
pw.println("====")
classes.foreach(source => pw.println(DefaultShowAPI(source)))
} finally pw.close()
}
Expand Down
21 changes: 14 additions & 7 deletions compiler/src/dotty/tools/dotc/sbt/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.Symbols.Symbol
import dotty.tools.dotc.core.NameOps.stripModuleClassSuffix
import dotty.tools.dotc.core.Names.Name
import dotty.tools.dotc.core.Names.termName
import dotty.tools.dotc.core.NameKinds.QualifiedNameKind

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

extension (sym: Symbol)

def constructorName(using Context) =
sym.owner.name ++ ";init;"

/** Mangle a JVM symbol name in a format better suited for internal uses by sbt. */
def zincMangledName(using Context): Name =
if (sym.isConstructor) constructorName
else sym.name.stripModuleClassSuffix
/** Mangle a JVM symbol name in a format better suited for internal uses by sbt.
* WARNING: output must not be written to TASTy, as it is not a valid TASTy name.
*/
private[sbt] def zincMangledName(using Context): Name =
if sym.isConstructor then
// TODO: ideally we should avoid unnecessarily caching these Zinc specific
// names in the global chars array. But we would need to restructure
// ExtractDependencies caches to avoid expensive `toString` on
// each member reference.
termName(sym.owner.fullName.mangledString.replace(".", ";").nn ++ ";init;")
else
sym.name.stripModuleClassSuffix
2 changes: 1 addition & 1 deletion sbt-bridge/test/xsbt/ExtractUsedNamesSpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class ExtractUsedNamesSpecification {
// All classes extend Object
"Object",
// All classes have a default constructor called <init>
"Object;init;",
"java;lang;Object;init;",
// the return type of the default constructor is Unit
"Unit"
)
Expand Down

0 comments on commit 73ee8b4

Please sign in to comment.