@@ -133,7 +133,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
133133 def mappedInfo =
134134 if toBeUpdated.contains(sym)
135135 then symd.info // don't transform symbols that will anyway be updated
136- else Fresh .fromCap( transformExplicitType(symd.info, sym), sym).tap(addOwnerAsHidden(_, sym) )
136+ else transformExplicitType(symd.info, sym, freshen = true )
137137 if Synthetics .needsTransform(symd) then
138138 Synthetics .transform(symd, mappedInfo)
139139 else if isPreCC(sym) then
@@ -331,7 +331,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
331331 * 5. Schedule deferred well-formed tests for types with retains annotations.
332332 * 6. Perform normalizeCaptures
333333 */
334- private def transformExplicitType (tp : Type , sym : Symbol , tptToCheck : Tree = EmptyTree )(using Context ): Type =
334+ private def transformExplicitType (tp : Type , sym : Symbol , freshen : Boolean , tptToCheck : Tree = EmptyTree )(using Context ): Type =
335335
336336 def fail (msg : Message ) =
337337 if ! tptToCheck.isEmpty then report.error(msg, tptToCheck.srcPos)
@@ -453,10 +453,13 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
453453 tp2
454454
455455 val tp1 = transform(tp)
456- if toCapturing.keptFunAliases then
457- toCapturing.keepFunAliases = false
458- transform(tp1)
459- else tp1
456+ val tp2 =
457+ if toCapturing.keptFunAliases then
458+ toCapturing.keepFunAliases = false
459+ transform(tp1)
460+ else tp1
461+ if freshen then Fresh .fromCap(tp2).tap(addOwnerAsHidden(_, sym))
462+ else tp2
460463 end transformExplicitType
461464
462465 /** Substitute parameter symbols in `from` to paramRefs in corresponding
@@ -537,16 +540,12 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
537540 var transformed =
538541 if tree.isInferred
539542 then transformInferredType(tree.tpe)
540- else
541- val transformed = transformExplicitType(tree.tpe, sym, tptToCheck = tree)
542- if boxed then transformed
543- else Fresh .fromCap(transformed, sym).tap(addOwnerAsHidden(_, sym))
543+ else transformExplicitType(tree.tpe, sym, freshen = ! boxed, tptToCheck = tree)
544544 if boxed then transformed = box(transformed)
545545 if sym.is(Param ) && (transformed ne tree.tpe) then
546546 paramSigChange += tree
547547 tree.setNuType(
548- if boxed then transformed
549- else if sym.hasAnnotation(defn.UncheckedCapturesAnnot ) then makeUnchecked(transformed)
548+ if sym.hasAnnotation(defn.UncheckedCapturesAnnot ) then makeUnchecked(transformed)
550549 else transformed)
551550
552551 /** Transform the type of a val or var or the result type of a def */
@@ -758,7 +757,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
758757
759758 // Compute new parent types
760759 val ps1 = inContext(ctx.withOwner(cls)):
761- ps.mapConserve(transformExplicitType(_, NoSymbol ))
760+ ps.mapConserve(transformExplicitType(_, NoSymbol , freshen = false ))
762761
763762 // Install new types and if it is a module class also update module object
764763 if (selfInfo1 ne selfInfo) || (ps1 ne ps) then
0 commit comments