@@ -602,13 +602,6 @@ class CheckCaptures extends Recheck, SymTransformer:
602602 * otherwise return NoType.
603603 */
604604 private def recheckUnsafeApply (tree : Apply , pt : Type )(using Context ): Type =
605-
606- def mapArgUsing (f : Type => Type ) =
607- val arg :: Nil = tree.args: @ unchecked
608- val argType0 = f(recheckStart(arg, pt))
609- val argType = super .recheckFinish(argType0, arg, pt)
610- super .recheckFinish(argType, tree, pt)
611-
612605 val meth = tree.fun.symbol
613606 if meth == defn.Caps_unsafeAssumePure then
614607 val arg :: Nil = tree.args: @ unchecked
@@ -618,31 +611,25 @@ class CheckCaptures extends Recheck, SymTransformer:
618611 else argType0.widen.stripCapturing
619612 capt.println(i " rechecking $arg with $pt: $argType" )
620613 super .recheckFinish(argType, tree, pt)
621- else if meth == defn.Caps_unsafeBox then
622- mapArgUsing(_.forceBoxStatus(true ))
623- else if meth == defn.Caps_unsafeUnbox then
624- mapArgUsing(_.forceBoxStatus(false ))
625- else if meth == defn.Caps_unsafeBoxFunArg then
626- def forceBox (tp : Type ): Type = tp.strippedDealias match
627- case defn.FunctionOf (paramtpe :: Nil , restpe, isContextual) =>
628- defn.FunctionOf (paramtpe.forceBoxStatus(true ) :: Nil , restpe, isContextual)
629- case tp @ RefinedType (parent, rname, rinfo : MethodType ) =>
630- tp.derivedRefinedType(parent, rname,
631- rinfo.derivedLambdaType(
632- paramInfos = rinfo.paramInfos.map(_.forceBoxStatus(true ))))
633- case tp @ CapturingType (parent, refs) =>
634- tp.derivedCapturingType(forceBox(parent), refs)
635- mapArgUsing(forceBox)
636614 else NoType
637615 end recheckUnsafeApply
638616
639- /** Recheck applications. More work is done in `recheckApplication`,
640- * `recheckArg` and `instantiate` below.
617+ /** Recheck applications, with special handling of unsafeAssumePure.
618+ * More work is done in `recheckApplication`, `recheckArg` and `instantiate` below.
641619 */
642620 override def recheckApply (tree : Apply , pt : Type )(using Context ): Type =
643- recheckUnsafeApply(tree, pt).orElse:
621+ val meth = tree.fun.symbol
622+ if meth == defn.Caps_unsafeAssumePure then
623+ val arg :: Nil = tree.args: @ unchecked
624+ val argType0 = recheck(arg, pt.capturing(CaptureSet .universal))
625+ val argType =
626+ if argType0.captureSet.isAlwaysEmpty then argType0
627+ else argType0.widen.stripCapturing
628+ capt.println(i " rechecking $arg with $pt: $argType" )
629+ super .recheckFinish(argType, tree, pt)
630+ else
644631 val res = super .recheckApply(tree, pt)
645- includeCallCaptures(tree.symbol , res, tree.srcPos)
632+ includeCallCaptures(meth , res, tree.srcPos)
646633 res
647634
648635 /** Recheck argument, and, if formal parameter carries a `@use`,
0 commit comments