@@ -133,7 +133,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
133
133
def mappedInfo =
134
134
if toBeUpdated.contains(sym)
135
135
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 )
137
137
if Synthetics .needsTransform(symd) then
138
138
Synthetics .transform(symd, mappedInfo)
139
139
else if isPreCC(sym) then
@@ -331,7 +331,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
331
331
* 5. Schedule deferred well-formed tests for types with retains annotations.
332
332
* 6. Perform normalizeCaptures
333
333
*/
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 =
335
335
336
336
def fail (msg : Message ) =
337
337
if ! tptToCheck.isEmpty then report.error(msg, tptToCheck.srcPos)
@@ -453,10 +453,13 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
453
453
tp2
454
454
455
455
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
460
463
end transformExplicitType
461
464
462
465
/** Substitute parameter symbols in `from` to paramRefs in corresponding
@@ -537,16 +540,12 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
537
540
var transformed =
538
541
if tree.isInferred
539
542
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)
544
544
if boxed then transformed = box(transformed)
545
545
if sym.is(Param ) && (transformed ne tree.tpe) then
546
546
paramSigChange += tree
547
547
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)
550
549
else transformed)
551
550
552
551
/** 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:
758
757
759
758
// Compute new parent types
760
759
val ps1 = inContext(ctx.withOwner(cls)):
761
- ps.mapConserve(transformExplicitType(_, NoSymbol ))
760
+ ps.mapConserve(transformExplicitType(_, NoSymbol , freshen = false ))
762
761
763
762
// Install new types and if it is a module class also update module object
764
763
if (selfInfo1 ne selfInfo) || (ps1 ne ps) then
0 commit comments