Skip to content

Commit a2d86e8

Browse files
committed
Use Dotty naming scheme and toString
1 parent cfded3e commit a2d86e8

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
207207

208208
val selfType = apiType(sym.givenSelfType)
209209

210-
val name = sym.fullName.stripModuleClassSuffix.mangledString
210+
val name = sym.fullName.toString
211211

212212
val tparams = sym.typeParams.map(apiTypeParameter).toArray
213213

@@ -241,7 +241,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
241241

242242
val javaPlatform = ctx.platform.asInstanceOf[JavaPlatform]
243243
if (sym.isStatic && defType == DefinitionType.Module && javaPlatform.hasJavaMainMethod(sym)) {
244-
_mainClasses += name
244+
_mainClasses += sym.fullName.stripModuleClassSuffix.toString // required for sbt to find the static main method
245245
}
246246

247247
api.ClassLikeDef.of(name, acc, modifiers, anns, tparams, defType)
@@ -316,7 +316,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
316316
if (aIsClass == bIsClass) {
317317
if (aIsClass) {
318318
if (a.is(Module) == b.is(Module))
319-
a.fullName.mangledString.compareTo(b.fullName.mangledString)
319+
a.fullName.toString.compareTo(b.fullName.toString)
320320
else if (a.is(Module))
321321
-1
322322
else
@@ -340,10 +340,10 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
340340
} else if (sym.isType) {
341341
apiTypeMember(sym.asType)
342342
} else if (sym.is(Mutable, butNot = Accessor)) {
343-
api.Var.of(sym.name.mangledString, apiAccess(sym), apiModifiers(sym),
343+
api.Var.of(sym.name.toString, apiAccess(sym), apiModifiers(sym),
344344
apiAnnotations(sym).toArray, apiType(sym.info))
345345
} else if (sym.isStable) {
346-
api.Val.of(sym.name.mangledString, apiAccess(sym), apiModifiers(sym),
346+
api.Val.of(sym.name.toString, apiAccess(sym), apiModifiers(sym),
347347
apiAnnotations(sym).toArray, apiType(sym.info))
348348
} else {
349349
apiDef(sym.asTerm)
@@ -370,7 +370,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
370370
} else
371371
(0 until pnames.length).map(Function.const(false))
372372
val params = (pnames, ptypes, defaults).zipped.map((pname, ptype, isDefault) =>
373-
api.MethodParameter.of(pname.mangledString, apiType(ptype),
373+
api.MethodParameter.of(pname.toString, apiType(ptype),
374374
isDefault, api.ParameterModifier.Plain))
375375
api.ParameterList.of(params.toArray, mt.isImplicitMethod) :: paramLists(restpe, params.length)
376376
case _ =>
@@ -380,20 +380,20 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
380380
val tparams = sym.info match {
381381
case pt: TypeLambda =>
382382
(pt.paramNames, pt.paramInfos).zipped.map((pname, pbounds) =>
383-
apiTypeParameter(pname.mangledString, 0, pbounds.lo, pbounds.hi))
383+
apiTypeParameter(pname.toString, 0, pbounds.lo, pbounds.hi))
384384
case _ =>
385385
Nil
386386
}
387387
val vparamss = paramLists(sym.info)
388388
val retTp = sym.info.finalResultType.widenExpr
389389

390-
api.Def.of(sym.name.mangledString, apiAccess(sym), apiModifiers(sym),
390+
api.Def.of(sym.name.toString, apiAccess(sym), apiModifiers(sym),
391391
apiAnnotations(sym).toArray, tparams.toArray, vparamss.toArray, apiType(retTp))
392392
}
393393

394394
def apiTypeMember(sym: TypeSymbol): api.TypeMember = {
395395
val typeParams = Array[api.TypeParameter]()
396-
val name = sym.name.mangledString
396+
val name = sym.name.toString
397397
val access = apiAccess(sym)
398398
val modifiers = apiModifiers(sym)
399399
val as = apiAnnotations(sym)
@@ -439,7 +439,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
439439
sym.owner.thisType
440440
else
441441
tp.prefix
442-
api.Projection.of(apiType(prefix), sym.name.mangledString)
442+
api.Projection.of(apiType(prefix), sym.name.toString)
443443
case AppliedType(tycon, args) =>
444444
def processArg(arg: Type): api.Type = arg match {
445445
case arg @ TypeBounds(lo, hi) => // Handle wildcard parameters
@@ -463,7 +463,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
463463
val apiRes = apiType(tl.resType)
464464
api.Polymorphic.of(apiRes, apiTparams.toArray)
465465
case rt: RefinedType =>
466-
val name = rt.refinedName.mangledString
466+
val name = rt.refinedName.toString
467467
val parent = apiType(rt.parent)
468468

469469
def typeRefinement(name: String, tp: TypeBounds): api.TypeMember = tp match {
@@ -536,7 +536,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
536536
case tp: ParamRef =>
537537
// TODO: Distinguishing parameters based on their names alone is not enough,
538538
// the binder is also needed (at least for type lambdas).
539-
api.ParameterRef.of(tp.paramName.mangledString)
539+
api.ParameterRef.of(tp.paramName.toString)
540540
case tp: LazyRef =>
541541
apiType(tp.ref)
542542
case tp: TypeVar =>
@@ -557,12 +557,12 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
557557

558558
def apiThis(sym: Symbol): api.Singleton = {
559559
val pathComponents = sym.ownersIterator.takeWhile(!_.isEffectiveRoot)
560-
.map(s => api.Id.of(s.name.mangledString))
560+
.map(s => api.Id.of(s.name.toString))
561561
api.Singleton.of(api.Path.of(pathComponents.toArray.reverse ++ Array(Constants.thisPath)))
562562
}
563563

564564
def apiTypeParameter(tparam: ParamInfo): api.TypeParameter =
565-
apiTypeParameter(tparam.paramName.mangledString, tparam.paramVariance,
565+
apiTypeParameter(tparam.paramName.toString, tparam.paramVariance,
566566
tparam.paramInfo.bounds.lo, tparam.paramInfo.bounds.hi)
567567

568568
def apiTypeParameter(name: String, variance: Int, lo: Type, hi: Type): api.TypeParameter =
@@ -590,7 +590,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
590590
if (sym.privateWithin eq NoSymbol)
591591
Constants.unqualified
592592
else
593-
api.IdQualifier.of(sym.privateWithin.fullName.mangledString)
593+
api.IdQualifier.of(sym.privateWithin.fullName.toString)
594594
if (sym.is(Protected))
595595
api.Protected.of(qualifier)
596596
else

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class ExtractDependencies extends Phase {
8989
case (rawClassName, usedNames) =>
9090
val className = rawClassName
9191
usedNames.defaultNames.foreach { rawUsedName =>
92-
val useName = rawUsedName.stripModuleClassSuffix.mangledString
92+
val useName = rawUsedName.toString
9393
val useScopes =
9494
usedNames.scopedNames.get(rawUsedName) match {
9595
case None => EnumSet.of(UseScope.Default)
@@ -179,7 +179,7 @@ class ExtractDependencies extends Phase {
179179

180180
object ExtractDependencies {
181181
def classNameAsString(sym: Symbol)(implicit ctx: Context): String =
182-
sym.fullName.stripModuleClassSuffix.mangledString // fullName in scalac strips module class suffix
182+
sym.fullName.toString
183183

184184
def isLocal(sym: Symbol)(implicit ctx: Context): Boolean =
185185
sym.ownersIterator.exists(_.isTerm)
@@ -294,7 +294,7 @@ private class ExtractDependenciesCollector(responsibleForImports: Symbol)(implic
294294
private class PatMatDependencyTraverser(ctx0: Context) extends ExtractTypesCollector(ctx0) {
295295
override protected def addDependency(symbol: Symbol)(implicit ctx: Context): Unit = {
296296
if (!ignoreDependency(symbol) && symbol.is(Sealed)) {
297-
val encName = nonLocalEnclosingClass(ctx.owner).fullName.stripModuleClassSuffix.mangledString
297+
val encName = nonLocalEnclosingClass(ctx.owner).fullName.toString
298298
val nameUsed = _usedNames.getOrElseUpdate(encName, new NameUsedInClass)
299299

300300
nameUsed.defaultNames += symbol.name

0 commit comments

Comments
 (0)