Skip to content

Commit 6f9e565

Browse files
committed
Drop unnecessary code in transformSym
The only time a nested object class could have a self type with a non-empty capture set is when it declared in the current compilation unit. Then that capture set is a Var that gets installed via an updateInfo. But then we do also an updateInfo of the module val, so no need to do the same thing in transformSym.
1 parent dd80312 commit 6f9e565

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
125125
symd.copySymDenotation(info = fluidify(sym.info))
126126
else if symd.owner.isTerm || symd.is(CaptureChecked) || symd.owner.is(CaptureChecked) then
127127
val newFlags = newFlagsFor(symd)
128-
var newInfo = mappedInfo
129-
if sym.is(ModuleVal) && !sym.isStatic then
130-
val selfType1 = transformSelfType(sym.moduleClass)
131-
if selfType1.exists then
132-
newInfo = newInfo.capturing(selfType1.captureSet)
133-
sym.termRef.invalidateCaches()
128+
val newInfo = mappedInfo
134129
if sym.isClass then
135130
sym.thisType.asInstanceOf[ThisType].invalidateCaches()
136131
if newFlags != symd.flags || (newInfo ne sym.info)
@@ -140,12 +135,6 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
140135
else symd
141136
end transformSym
142137

143-
def transformSelfType(sym: Symbol)(using Context) = (sym.info: @unchecked) match
144-
case ClassInfo(_, cls, _, _, selfInfo: Type) =>
145-
inContext(ctx.withOwner(cls)):
146-
transformExplicitType(selfInfo, rootTarget = ctx.owner)
147-
case _ => NoType
148-
149138
/** If `tp` is an unboxed capturing type or a function returning an unboxed capturing type,
150139
* convert it to be boxed.
151140
*/

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
24112411
/** The least upper bound of two types
24122412
* @param canConstrain If true, new constraints might be added to simplify the lub.
24132413
* @param isSoft If the lub is a union, this determines whether it's a soft union.
2414-
* @note We do not admit singleton types in or-types as lubs.
24152414
*/
24162415
def lub(tp1: Type, tp2: Type, canConstrain: Boolean = false, isSoft: Boolean = true): Type = /*>|>*/ trace(s"lub(${tp1.show}, ${tp2.show}, canConstrain=$canConstrain, isSoft=$isSoft)", subtyping, show = true) /*<|<*/ {
24172416
if (tp1 eq tp2) tp1

0 commit comments

Comments
 (0)