@@ -333,22 +333,29 @@ class CheckCaptures extends Recheck, SymTransformer:
333333 */
334334 override def recheckApply (tree : Apply , pt : Type )(using Context ): Type =
335335 includeCallCaptures(tree.symbol, tree.srcPos)
336- super .recheckApply(tree, pt) match
337- case appType @ CapturingType (appType1, refs) =>
338- tree.fun match
339- case Select (qual, _)
340- if ! tree.fun.symbol.isConstructor
341- && ! qual.tpe.isBoxedCapturing
342- && ! tree.args.exists(_.tpe.isBoxedCapturing)
343- && qual.tpe.captureSet.mightSubcapture(refs)
344- && tree.args.forall(_.tpe.captureSet.mightSubcapture(refs))
345- =>
346- val callCaptures = tree.args.foldLeft(qual.tpe.captureSet)((cs, arg) =>
347- cs ++ arg.tpe.captureSet)
348- appType.derivedCapturingType(appType1, callCaptures)
349- .showing(i " narrow $tree: $appType, refs = $refs, qual = ${qual.tpe.captureSet} --> $result" , capt)
350- case _ => appType
351- case appType => appType
336+ tree match
337+ case Apply (fn, arg :: Nil ) if fn.symbol == defn.Caps_unsafeUnbox =>
338+ val argType0 = recheckStart(arg, pt).unbox
339+ val argType = super .recheckFinish(argType0, arg, pt)
340+ super .recheckFinish(argType, tree, pt)
341+ case _ =>
342+ super .recheckApply(tree, pt) match
343+ case appType @ CapturingType (appType1, refs) =>
344+ tree.fun match
345+ case Select (qual, _)
346+ if ! tree.fun.symbol.isConstructor
347+ && ! qual.tpe.isBoxedCapturing
348+ && ! tree.args.exists(_.tpe.isBoxedCapturing)
349+ && qual.tpe.captureSet.mightSubcapture(refs)
350+ && tree.args.forall(_.tpe.captureSet.mightSubcapture(refs))
351+ =>
352+ val callCaptures = tree.args.foldLeft(qual.tpe.captureSet)((cs, arg) =>
353+ cs ++ arg.tpe.captureSet)
354+ appType.derivedCapturingType(appType1, callCaptures)
355+ .showing(i " narrow $tree: $appType, refs = $refs, qual = ${qual.tpe.captureSet} --> $result" , capt)
356+ case _ => appType
357+ case appType => appType
358+ end recheckApply
352359
353360 /** Handle an application of method `sym` with type `mt` to arguments of types `argTypes`.
354361 * This means:
0 commit comments