Skip to content

Commit b3c4717

Browse files
committed
Map parents of classes with the class as owner.
Also: Print local roots with id of owner under -uniqid
1 parent 9be0f6f commit b3c4717

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,10 +613,11 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
613613
// why the class was picked as level owner. But self types should not be able
614614
// to mention other fields.
615615
val newSelfType = CapturingType(cinfo.selfType, CaptureSet.Var(cls))
616-
ccSetup.println(i"mapped self type for $cls: $newSelfType, was $selfInfo")
617-
val ps1 = ps.mapConserve(transformExplicitType(_, rootTarget = ctx.owner))
616+
val ps1 = inContext(ctx.withOwner(cls)):
617+
ps.mapConserve(transformExplicitType(_, rootTarget = cls))
618618
val newInfo = ClassInfo(prefix, cls, ps1, decls, newSelfType)
619619
updateInfo(cls, newInfo)
620+
ccSetup.println(i"update class info of $cls with parents $ps selfinfo $selfInfo to $newInfo")
620621
cls.thisType.asInstanceOf[ThisType].invalidateCaches()
621622
if cls.is(ModuleClass) then
622623
// if it's a module, the capture set of the module reference is the capture set of the self type

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5962,17 +5962,16 @@ object Types {
59625962
}
59635963

59645964
/** A type map that maps also parents and self type of a ClassInfo */
5965-
abstract class DeepTypeMap(using Context) extends TypeMap {
5966-
override def mapClassInfo(tp: ClassInfo): ClassInfo = {
5965+
abstract class DeepTypeMap(using Context) extends TypeMap:
5966+
override def mapClassInfo(tp: ClassInfo): ClassInfo =
59675967
val prefix1 = this(tp.prefix)
5968-
val parents1 = tp.declaredParents mapConserve this
5969-
val selfInfo1: TypeOrSymbol = tp.selfInfo match {
5970-
case selfInfo: Type => inContext(ctx.withOwner(tp.cls))(this(selfInfo))
5971-
case selfInfo => selfInfo
5972-
}
5973-
tp.derivedClassInfo(prefix1, parents1, tp.decls, selfInfo1)
5974-
}
5975-
}
5968+
inContext(ctx.withOwner(tp.cls)):
5969+
val parents1 = tp.declaredParents.mapConserve(this)
5970+
val selfInfo1: TypeOrSymbol = tp.selfInfo match
5971+
case selfInfo: Type => inContext(ctx.withOwner(tp.cls))(this(selfInfo))
5972+
case selfInfo => selfInfo
5973+
tp.derivedClassInfo(prefix1, parents1, tp.decls, selfInfo1)
5974+
end DeepTypeMap
59765975

59775976
@sharable object IdentityTypeMap extends TypeMap()(NoContext) {
59785977
def apply(tp: Type): Type = tp

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
407407
if tp.symbol.name == nme.LOCAL_CAPTURE_ROOT then // TODO: Move to toTextCaptureRef
408408
if ctx.owner.levelOwner == tp.localRootOwner && !printDebug && shortenCap
409409
then Str("cap")
410-
else Str(s"cap[${tp.localRootOwner.name}]")
410+
else Str(s"cap[${nameString(tp.localRootOwner)}]")
411411
else toTextPrefixOf(tp) ~ selectionString(tp)
412412
case tp: ThisType =>
413413
nameString(tp.cls) + ".this"

0 commit comments

Comments
 (0)