@@ -607,13 +607,6 @@ class CheckCaptures extends Recheck, SymTransformer:
607
607
* otherwise return NoType.
608
608
*/
609
609
private def recheckUnsafeApply (tree : Apply , pt : Type )(using Context ): Type =
610
-
611
- def mapArgUsing (f : Type => Type ) =
612
- val arg :: Nil = tree.args: @ unchecked
613
- val argType0 = f(recheckStart(arg, pt))
614
- val argType = super .recheckFinish(argType0, arg, pt)
615
- super .recheckFinish(argType, tree, pt)
616
-
617
610
val meth = tree.fun.symbol
618
611
if meth == defn.Caps_unsafeAssumePure then
619
612
val arg :: Nil = tree.args: @ unchecked
@@ -623,31 +616,25 @@ class CheckCaptures extends Recheck, SymTransformer:
623
616
else argType0.widen.stripCapturing
624
617
capt.println(i " rechecking $arg with $pt: $argType" )
625
618
super .recheckFinish(argType, tree, pt)
626
- else if meth == defn.Caps_unsafeBox then
627
- mapArgUsing(_.forceBoxStatus(true ))
628
- else if meth == defn.Caps_unsafeUnbox then
629
- mapArgUsing(_.forceBoxStatus(false ))
630
- else if meth == defn.Caps_unsafeBoxFunArg then
631
- def forceBox (tp : Type ): Type = tp.strippedDealias match
632
- case defn.FunctionOf (paramtpe :: Nil , restpe, isContextual) =>
633
- defn.FunctionOf (paramtpe.forceBoxStatus(true ) :: Nil , restpe, isContextual)
634
- case tp @ RefinedType (parent, rname, rinfo : MethodType ) =>
635
- tp.derivedRefinedType(parent, rname,
636
- rinfo.derivedLambdaType(
637
- paramInfos = rinfo.paramInfos.map(_.forceBoxStatus(true ))))
638
- case tp @ CapturingType (parent, refs) =>
639
- tp.derivedCapturingType(forceBox(parent), refs)
640
- mapArgUsing(forceBox)
641
619
else NoType
642
620
end recheckUnsafeApply
643
621
644
- /** Recheck applications. More work is done in `recheckApplication`,
645
- * `recheckArg` and `instantiate` below.
622
+ /** Recheck applications, with special handling of unsafeAssumePure.
623
+ * More work is done in `recheckApplication`, `recheckArg` and `instantiate` below.
646
624
*/
647
625
override def recheckApply (tree : Apply , pt : Type )(using Context ): Type =
648
- recheckUnsafeApply(tree, pt).orElse:
626
+ val meth = tree.fun.symbol
627
+ if meth == defn.Caps_unsafeAssumePure then
628
+ val arg :: Nil = tree.args: @ unchecked
629
+ val argType0 = recheck(arg, pt.capturing(CaptureSet .universal))
630
+ val argType =
631
+ if argType0.captureSet.isAlwaysEmpty then argType0
632
+ else argType0.widen.stripCapturing
633
+ capt.println(i " rechecking $arg with $pt: $argType" )
634
+ super .recheckFinish(argType, tree, pt)
635
+ else
649
636
val res = super .recheckApply(tree, pt)
650
- includeCallCaptures(tree.symbol , res, tree.srcPos)
637
+ includeCallCaptures(meth , res, tree.srcPos)
651
638
res
652
639
653
640
/** Recheck argument, and, if formal parameter carries a `@use`,
0 commit comments