@@ -437,9 +437,11 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
437
437
transformTT(arg, boxed = true , exact = false ) // type arguments in type applications are boxed
438
438
439
439
case tree : TypeDef if tree.symbol.isClass =>
440
- ccState.recordLevel(tree.symbol)
441
- inContext(ctx.withOwner(tree.symbol)):
442
- traverseChildren(tree)
440
+ val sym = tree.symbol
441
+ ccState.recordLevel(sym)
442
+ ccState.inNestedLevelUnless(sym.is(Module )):
443
+ inContext(ctx.withOwner(sym))
444
+ traverseChildren(tree)
443
445
444
446
case tree @ SeqLiteral (elems, tpt : TypeTree ) =>
445
447
traverse(elems)
@@ -546,36 +548,37 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
546
548
case tree : TypeDef =>
547
549
tree.symbol match
548
550
case cls : ClassSymbol =>
549
- val cinfo @ ClassInfo (prefix, _, ps, decls, selfInfo) = cls.classInfo
550
- def innerModule = cls.is(ModuleClass ) && ! cls.isStatic
551
- val selfInfo1 =
552
- if (selfInfo ne NoType ) && ! innerModule then
553
- // if selfInfo is explicitly given then use that one, except if
554
- // self info applies to non-static modules, these still need to be inferred
555
- selfInfo
556
- else if cls.isPureClass then
557
- // is cls is known to be pure, nothing needs to be added to self type
558
- selfInfo
559
- else if ! cls.isEffectivelySealed && ! cls.baseClassHasExplicitSelfType then
560
- // assume {cap} for completely unconstrained self types of publicly extensible classes
561
- CapturingType (cinfo.selfType, CaptureSet .universal)
562
- else
563
- // Infer the self type for the rest, which is all classes without explicit
564
- // self types (to which we also add nested module classes), provided they are
565
- // neither pure, nor are publicily extensible with an unconstrained self type.
566
- CapturingType (cinfo.selfType, CaptureSet .Var (cls, level = ccState.currentLevel))
567
- val ps1 = inContext(ctx.withOwner(cls)):
568
- ps.mapConserve(transformExplicitType(_))
569
- if (selfInfo1 ne selfInfo) || (ps1 ne ps) then
570
- val newInfo = ClassInfo (prefix, cls, ps1, decls, selfInfo1)
571
- updateInfo(cls, newInfo)
572
- capt.println(i " update class info of $cls with parents $ps selfinfo $selfInfo to $newInfo" )
573
- cls.thisType.asInstanceOf [ThisType ].invalidateCaches()
574
- if cls.is(ModuleClass ) then
575
- // if it's a module, the capture set of the module reference is the capture set of the self type
576
- val modul = cls.sourceModule
577
- updateInfo(modul, CapturingType (modul.info, selfInfo1.asInstanceOf [Type ].captureSet))
578
- modul.termRef.invalidateCaches()
551
+ ccState.inNestedLevelUnless(cls.is(Module )):
552
+ val cinfo @ ClassInfo (prefix, _, ps, decls, selfInfo) = cls.classInfo
553
+ def innerModule = cls.is(ModuleClass ) && ! cls.isStatic
554
+ val selfInfo1 =
555
+ if (selfInfo ne NoType ) && ! innerModule then
556
+ // if selfInfo is explicitly given then use that one, except if
557
+ // self info applies to non-static modules, these still need to be inferred
558
+ selfInfo
559
+ else if cls.isPureClass then
560
+ // is cls is known to be pure, nothing needs to be added to self type
561
+ selfInfo
562
+ else if ! cls.isEffectivelySealed && ! cls.baseClassHasExplicitSelfType then
563
+ // assume {cap} for completely unconstrained self types of publicly extensible classes
564
+ CapturingType (cinfo.selfType, CaptureSet .universal)
565
+ else
566
+ // Infer the self type for the rest, which is all classes without explicit
567
+ // self types (to which we also add nested module classes), provided they are
568
+ // neither pure, nor are publicily extensible with an unconstrained self type.
569
+ CapturingType (cinfo.selfType, CaptureSet .Var (cls, level = ccState.currentLevel))
570
+ val ps1 = inContext(ctx.withOwner(cls)):
571
+ ps.mapConserve(transformExplicitType(_))
572
+ if (selfInfo1 ne selfInfo) || (ps1 ne ps) then
573
+ val newInfo = ClassInfo (prefix, cls, ps1, decls, selfInfo1)
574
+ updateInfo(cls, newInfo)
575
+ capt.println(i " update class info of $cls with parents $ps selfinfo $selfInfo to $newInfo" )
576
+ cls.thisType.asInstanceOf [ThisType ].invalidateCaches()
577
+ if cls.is(ModuleClass ) then
578
+ // if it's a module, the capture set of the module reference is the capture set of the self type
579
+ val modul = cls.sourceModule
580
+ updateInfo(modul, CapturingType (modul.info, selfInfo1.asInstanceOf [Type ].captureSet))
581
+ modul.termRef.invalidateCaches()
579
582
case _ =>
580
583
case _ =>
581
584
end postProcess
0 commit comments