@@ -843,8 +843,7 @@ class CheckCaptures extends Recheck, SymTransformer:
843843 for (getterName, argType) <- mt.paramNames.lazyZip(argTypes) do
844844 val getter = cls.info.member(getterName).suchThat(_.isRefiningParamAccessor).symbol
845845 if ! getter.is(Private ) && getter.hasTrackedParts then
846- refined = RefinedType (refined, getterName,
847- AnnotatedType (argType.unboxed, Annotation (defn.RefineOverrideAnnot , util.Spans .NoSpan ))) // Yichen you might want to check this
846+ refined = refined.refinedOverride(getterName, argType.unboxed) // Yichen you might want to check this
848847 allCaptures ++= argType.captureSet
849848 (refined, allCaptures)
850849
@@ -1507,9 +1506,7 @@ class CheckCaptures extends Recheck, SymTransformer:
15071506 val cs = actual.captureSet
15081507 if covariant then cs ++ leaked
15091508 else
1510- if // CCState.withCapAsRoot: // Not sure withCapAsRoot is OK here, actually
1511- ! leaked.subCaptures(cs).isOK
1512- then
1509+ if ! leaked.subCaptures(cs).isOK then
15131510 report.error(
15141511 em """ $expected cannot be box-converted to ${actual.capturing(leaked)}
15151512 |since the additional capture set $leaked resulting from box conversion is not allowed in $actual""" , tree.srcPos)
@@ -1708,7 +1705,8 @@ class CheckCaptures extends Recheck, SymTransformer:
17081705 def traverse (t : Tree )(using Context ) =
17091706 t match
17101707 case t : Template =>
1711- checkAllOverrides(ctx.owner.asClass, OverridingPairsCheckerCC (_, _, t))
1708+ ignoringFreshLevels :
1709+ checkAllOverrides(ctx.owner.asClass, OverridingPairsCheckerCC (_, _, t))
17121710 case _ =>
17131711 traverseChildren(t)
17141712 end checkOverrides
@@ -1912,7 +1910,8 @@ class CheckCaptures extends Recheck, SymTransformer:
19121910 arg.withType(arg.nuType.forceBoxStatus(
19131911 bounds.hi.isBoxedCapturing | bounds.lo.isBoxedCapturing))
19141912 CCState .withCapAsRoot: // OK? We need this since bounds use `cap` instead of `fresh`
1915- checkBounds(normArgs, tl)
1913+ CCState .ignoringFreshLevels:
1914+ checkBounds(normArgs, tl)
19161915 if ccConfig.postCheckCapturesets then
19171916 args.lazyZip(tl.paramNames).foreach(checkTypeParam(_, _, fun.symbol))
19181917 case _ =>
@@ -1932,7 +1931,8 @@ class CheckCaptures extends Recheck, SymTransformer:
19321931 case tree : New =>
19331932 case tree : TypeTree =>
19341933 CCState .withCapAsRoot:
1935- checkAppliedTypesIn(tree.withType(tree.nuType))
1934+ CCState .ignoringFreshLevels:
1935+ checkAppliedTypesIn(tree.withType(tree.nuType))
19361936 case _ => traverseChildren(t)
19371937 checkApplied.traverse(unit)
19381938 end postCheck
0 commit comments