File tree 4 files changed +18
-6
lines changed
compiler/src/dotty/tools/dotc
4 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,8 @@ object NameTags extends TastyFormat.NameTags {
40
40
inline val EXPLICITFIELD = 38 // An explicitly named field, introduce to avoid a clash
41
41
// with a regular field of the underlying name
42
42
43
+ inline val ZINCMANGLED = 39 // a reserved tag for use in Zinc name mangling (replace `.` by `::`)
44
+
43
45
def nameTagToString (tag : Int ): String = tag match {
44
46
case UTF8 => " UTF8"
45
47
case QUALIFIED => " QUALIFIED"
@@ -61,6 +63,7 @@ object NameTags extends TastyFormat.NameTags {
61
63
case PARAMACC => " PARAMACC"
62
64
case ADAPTEDCLOSURE => " ADAPTEDCLOSURE"
63
65
case OBJECTCLASS => " OBJECTCLASS"
66
+ case ZINCMANGLED => " ZINCMANGLED"
64
67
65
68
case SIGNED => " SIGNED"
66
69
case TARGETSIGNED => " TARGETSIGNED"
Original file line number Diff line number Diff line change @@ -79,6 +79,9 @@ class ExtractAPI extends Phase {
79
79
val pw = new PrintWriter (File (sourceFile.file.jpath).changeExtension(" inc" ).toFile
80
80
.bufferedWriter(append = true ), true )
81
81
try {
82
+ pw.println()
83
+ pw.println(" API:" )
84
+ pw.println(" ====" )
82
85
classes.foreach(source => pw.println(DefaultShowAPI (source)))
83
86
} finally pw.close()
84
87
}
Original file line number Diff line number Diff line change @@ -4,17 +4,23 @@ import dotty.tools.dotc.core.Contexts.Context
4
4
import dotty .tools .dotc .core .Symbols .Symbol
5
5
import dotty .tools .dotc .core .NameOps .stripModuleClassSuffix
6
6
import dotty .tools .dotc .core .Names .Name
7
+ import dotty .tools .dotc .core .NameKinds .QualifiedNameKind
8
+ import dotty .tools .dotc .core .NameTags .ZINCMANGLED
7
9
8
10
inline val TermNameHash = 1987 // 300th prime
9
11
inline val TypeNameHash = 1993 // 301st prime
10
12
inline val InlineParamHash = 1997 // 302nd prime
11
13
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 )
13
18
14
- def constructorName (using Context ) =
15
- sym.owner.name ++ " ;init;"
19
+ extension (sym : Symbol )
16
20
17
- /** Mangle a JVM symbol name in a format better suited for internal uses by sbt. */
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
+ */
18
24
def zincMangledName (using Context ): Name =
19
- if (sym.isConstructor) constructorName
25
+ if (sym.isConstructor) sym.owner.fullNameSeparated( ZincMangledName ) ++ " ;init; "
20
26
else sym.name.stripModuleClassSuffix
Original file line number Diff line number Diff line change @@ -306,7 +306,7 @@ class ExtractUsedNamesSpecification {
306
306
// All classes extend Object
307
307
" Object" ,
308
308
// All classes have a default constructor called <init>
309
- " Object;init;" ,
309
+ " java::lang:: Object;init;" ,
310
310
// the return type of the default constructor is Unit
311
311
" Unit"
312
312
)
You can’t perform that action at this time.
0 commit comments