@@ -341,7 +341,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
341341 * the latter contains a cap.
342342 */
343343 private def formalCaptures (arg : Tree )(using Context ): Refs =
344- arg.formalType.orElse(arg.nuType).deepCaptureSet .elems
344+ arg.formalType.orElse(arg.nuType).spanCaptureSet .elems
345345
346346 /** The span capture set if the type of `tree` */
347347 private def spanCaptures (tree : Tree )(using Context ): Refs =
@@ -402,7 +402,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
402402 if clashIdx == 0 && ! isShowableMethod then " " // we already mentioned the type in `funStr`
403403 else i " with type ${clashing.nuType}"
404404 val hiddenSet = formalCaptures(polyArg).transHiddenSet
405- val clashSet = deepCaptures(clashing)
405+ val clashSet = if clashIdx == - 1 then deepCaptures(clashing) else spanCaptures (clashing)
406406 val hiddenFootprint = hiddenSet.directFootprint
407407 val clashFootprint = clashSet.directFootprint
408408 report.error(
@@ -891,10 +891,11 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
891891 val resultType = mtpe.finalResultType
892892 val resultCaptures =
893893 (resultArgCaptures(resultType) ++ resultType.deepCaptureSet.elems).filter(! isLocalRef(_))
894+ // See i23726.scala why deepCaptureSet is needed here.
894895 val resultPeaks = resultCaptures.allPeaks
895896 capt.println(i " deps for $app = ${deps.toList}" )
896897 (deps, resultPeaks)
897-
898+ end dependencies
898899
899900 /** Decompose an application into a function prefix and a list of argument lists.
900901 * If some of the arguments need a separation check because they are capture polymorphic,
0 commit comments