@@ -113,11 +113,9 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
113
113
def transformSym (symd : SymDenotation )(using Context ): SymDenotation =
114
114
if ! pastRecheck && Feature .ccEnabledSomewhere then
115
115
val sym = symd.symbol
116
- def rootTarget =
117
- if sym.isAliasType && sym.isStatic then NoSymbol else sym
118
116
def mappedInfo =
119
117
if toBeUpdated.contains(sym) then symd.info
120
- else transformExplicitType(symd.info, rootTarget )
118
+ else transformExplicitType(symd.info)
121
119
// TODO if sym is class && level owner: add a capture root
122
120
if Synthetics .needsTransform(symd) then
123
121
Synthetics .transform(symd, mappedInfo)
@@ -261,7 +259,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
261
259
private def transformInferredType (tp : Type )(using Context ): Type =
262
260
mapInferred(refine = true )(tp)
263
261
264
- private def transformExplicitType (tp : Type , rootTarget : Symbol , tptToCheck : Option [Tree ] = None )(using Context ): Type =
262
+ private def transformExplicitType (tp : Type , tptToCheck : Option [Tree ] = None )(using Context ): Type =
265
263
val expandAliases = new DeepTypeMap :
266
264
override def toString = " expand aliases"
267
265
@@ -314,9 +312,8 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
314
312
else t.info match
315
313
case TypeAlias (alias) =>
316
314
val transformed =
317
- if sym.isStatic then this (alias)
318
- else transformExplicitType(alias,
319
- if rootTarget.exists then sym else NoSymbol )(
315
+ if sym.isStatic || true then this (alias)
316
+ else transformExplicitType(alias)(
320
317
using ctx.withOwner(sym.owner))
321
318
if transformed ne alias then transformed else t
322
319
// .showing(i"EXPAND $t with ${t.info} to $result in ${t.symbol.owner}/${ctx.owner}")
@@ -367,13 +364,13 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
367
364
end transformExplicitType
368
365
369
366
/** Transform type of type tree, and remember the transformed type as the type the tree */
370
- private def transformTT (tree : TypeTree , boxed : Boolean , exact : Boolean , rootTarget : Symbol )(using Context ): Unit =
367
+ private def transformTT (tree : TypeTree , boxed : Boolean , exact : Boolean )(using Context ): Unit =
371
368
if ! tree.hasRememberedType then
372
369
val tp = if boxed then Box (tree.tpe) else tree.tpe
373
370
tree.rememberType(
374
371
if tree.isInstanceOf [InferredTypeTree ] && ! exact
375
372
then transformInferredType(tp)
376
- else transformExplicitType(tp, rootTarget, tptToCheck = Some (tree)))
373
+ else transformExplicitType(tp, tptToCheck = Some (tree)))
377
374
378
375
/** Substitute parameter symbols in `from` to paramRefs in corresponding
379
376
* method or poly types `to`. We use a single BiTypeMap to do everything.
@@ -428,12 +425,11 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
428
425
429
426
def transformResultType (tpt : TypeTree , sym : Symbol )(using Context ): Unit =
430
427
transformTT(tpt,
431
- boxed =
432
- ! allowUniversalInBoxed && sym.is(Mutable , butNot = Method ),
433
- // types of mutable variables are boxed in pre 3.3 codee
434
- exact = sym.allOverriddenSymbols.hasNext,
435
- // types of symbols that override a parent don't get a capture set TODO drop
436
- rootTarget = ctx.owner)
428
+ boxed = ! allowUniversalInBoxed && sym.is(Mutable , butNot = Method ),
429
+ // types of mutable variables are boxed in pre 3.3 codee
430
+ exact = sym.allOverriddenSymbols.hasNext,
431
+ // types of symbols that override a parent don't get a capture set TODO drop
432
+ )
437
433
val addDescription = new TypeTraverser :
438
434
def traverse (tp : Type ) = tp match
439
435
case tp @ CapturingType (parent, refs) =>
@@ -457,16 +453,6 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
457
453
// println(i"TYPE of ${tree.symbol.showLocated} = ${tpt.knownType}")
458
454
459
455
case tree @ ValDef (_, tpt : TypeTree , _) =>
460
- def containsCap (tp : Type ) = tp.existsPart:
461
- case CapturingType (_, refs) => refs.isUniversal
462
- case _ => false
463
- def mentionsCap (tree : Tree ): Boolean = tree match
464
- case Apply (fn, _) => mentionsCap(fn)
465
- case TypeApply (fn, args) => args.exists(mentionsCap)
466
- case _ : InferredTypeTree => false
467
- case _ : TypeTree => containsCap(transformExplicitType(tree.tpe, rootTarget = NoSymbol ))
468
- case _ => false
469
-
470
456
val sym = tree.symbol
471
457
val defCtx = if sym.isOneOf(TermParamOrAccessor ) then ctx else ctx.withOwner(sym)
472
458
inContext(defCtx):
@@ -480,7 +466,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
480
466
case tree @ TypeApply (fn, args) =>
481
467
traverse(fn)
482
468
for case arg : TypeTree <- args do
483
- transformTT(arg, boxed = true , exact = false , rootTarget = ctx.owner ) // type arguments in type applications are boxed
469
+ transformTT(arg, boxed = true , exact = false ) // type arguments in type applications are boxed
484
470
485
471
if allowUniversalInBoxed then
486
472
val polyType = fn.tpe.widen.asInstanceOf [TypeLambda ]
@@ -498,7 +484,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
498
484
499
485
case tree @ SeqLiteral (elems, tpt : TypeTree ) =>
500
486
traverse(elems)
501
- transformTT(tpt, boxed = true , exact = false , rootTarget = ctx.owner )
487
+ transformTT(tpt, boxed = true , exact = false )
502
488
503
489
case _ =>
504
490
traverseChildren(tree)
@@ -507,11 +493,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
507
493
508
494
def postProcess (tree : Tree )(using Context ): Unit = tree match
509
495
case tree : TypeTree =>
510
- val lowner =
511
- transformTT(tree, boxed = false , exact = false ,
512
- rootTarget = if ctx.owner.isStaticOwner then NoSymbol else ctx.owner
513
- // roots of other types in static locations are not mapped
514
- )
496
+ transformTT(tree, boxed = false , exact = false )
515
497
case tree : ValOrDefDef =>
516
498
val sym = tree.symbol
517
499
@@ -573,10 +555,8 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
573
555
else SubstParams (prevPsymss, prevLambdas)(resType)
574
556
575
557
if sym.exists && signatureChanges then
576
- def absInfo (resType : Type ): Type =
577
- integrateRT(sym.info, sym.paramSymss, resType, Nil , Nil )
558
+ val newInfo = integrateRT(sym.info, sym.paramSymss, localReturnType, Nil , Nil )
578
559
.showing(i " update info $sym: ${sym.info} = $result" , ccSetup)
579
- val newInfo = absInfo(localReturnType)
580
560
if newInfo ne sym.info then
581
561
val updatedInfo =
582
562
if sym.isAnonymousFunction
@@ -608,13 +588,9 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
608
588
val cinfo @ ClassInfo (prefix, _, ps, decls, selfInfo) = cls.classInfo
609
589
if (selfInfo eq NoType ) || cls.is(ModuleClass ) && ! cls.isStatic then
610
590
// add capture set to self type of nested classes if no self type is given explicitly.
611
- // It's unclear what the right level owner should be. A self type should
612
- // be able to mention class parameters, which are owned by the class; that's
613
- // why the class was picked as level owner. But self types should not be able
614
- // to mention other fields.
615
591
val newSelfType = CapturingType (cinfo.selfType, CaptureSet .Var (cls))
616
592
val ps1 = inContext(ctx.withOwner(cls)):
617
- ps.mapConserve(transformExplicitType(_, rootTarget = cls ))
593
+ ps.mapConserve(transformExplicitType(_))
618
594
val newInfo = ClassInfo (prefix, cls, ps1, decls, newSelfType)
619
595
updateInfo(cls, newInfo)
620
596
ccSetup.println(i " update class info of $cls with parents $ps selfinfo $selfInfo to $newInfo" )
0 commit comments