@@ -843,8 +843,7 @@ class CheckCaptures extends Recheck, SymTransformer:
843
843
for (getterName, argType) <- mt.paramNames.lazyZip(argTypes) do
844
844
val getter = cls.info.member(getterName).suchThat(_.isRefiningParamAccessor).symbol
845
845
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
848
847
allCaptures ++= argType.captureSet
849
848
(refined, allCaptures)
850
849
@@ -1507,9 +1506,7 @@ class CheckCaptures extends Recheck, SymTransformer:
1507
1506
val cs = actual.captureSet
1508
1507
if covariant then cs ++ leaked
1509
1508
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
1513
1510
report.error(
1514
1511
em """ $expected cannot be box-converted to ${actual.capturing(leaked)}
1515
1512
|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:
1708
1705
def traverse (t : Tree )(using Context ) =
1709
1706
t match
1710
1707
case t : Template =>
1711
- checkAllOverrides(ctx.owner.asClass, OverridingPairsCheckerCC (_, _, t))
1708
+ ignoringFreshLevels :
1709
+ checkAllOverrides(ctx.owner.asClass, OverridingPairsCheckerCC (_, _, t))
1712
1710
case _ =>
1713
1711
traverseChildren(t)
1714
1712
end checkOverrides
@@ -1912,7 +1910,8 @@ class CheckCaptures extends Recheck, SymTransformer:
1912
1910
arg.withType(arg.nuType.forceBoxStatus(
1913
1911
bounds.hi.isBoxedCapturing | bounds.lo.isBoxedCapturing))
1914
1912
CCState .withCapAsRoot: // OK? We need this since bounds use `cap` instead of `fresh`
1915
- checkBounds(normArgs, tl)
1913
+ CCState .ignoringFreshLevels:
1914
+ checkBounds(normArgs, tl)
1916
1915
if ccConfig.postCheckCapturesets then
1917
1916
args.lazyZip(tl.paramNames).foreach(checkTypeParam(_, _, fun.symbol))
1918
1917
case _ =>
@@ -1932,7 +1931,8 @@ class CheckCaptures extends Recheck, SymTransformer:
1932
1931
case tree : New =>
1933
1932
case tree : TypeTree =>
1934
1933
CCState .withCapAsRoot:
1935
- checkAppliedTypesIn(tree.withType(tree.nuType))
1934
+ CCState .ignoringFreshLevels:
1935
+ checkAppliedTypesIn(tree.withType(tree.nuType))
1936
1936
case _ => traverseChildren(t)
1937
1937
checkApplied.traverse(unit)
1938
1938
end postCheck
0 commit comments