Skip to content

Commit dfd077e

Browse files
committed
address review comments
1 parent fcf85ad commit dfd077e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,10 @@ class CheckCaptures extends Recheck, SymTransformer:
916916
case ref: TermParamRef => allowed.contains(ref)
917917
case _ => true
918918

919+
// Widen the given term parameter refs x₁ : C₁ S₁ , ⋯ , xₙ : Cₙ Sₙ to their capture sets C₁ , ⋯ , Cₙ.
920+
//
921+
// If in these capture sets there are any capture references that are term parameter references we should avoid,
922+
// we will widen them recursively.
919923
private def widenParamRefs(refs: List[TermParamRef]): List[CaptureSet] =
920924
@scala.annotation.tailrec
921925
def recur(todos: List[TermParamRef], acc: List[CaptureSet]): List[CaptureSet] =
@@ -954,13 +958,12 @@ class CheckCaptures extends Recheck, SymTransformer:
954958
healCaptureSet(refs)
955959
// mapOver(tp)
956960
traverseChildren(parent)
957-
case tp @ RefinedType(parent, rname, rinfo: MethodType) =>
961+
case tp @ RefinedType(parent, rname, rinfo: MethodType) if defn.isFunctionType(tp) =>
958962
traverseChildren(rinfo)
959963
case tp: TermLambda =>
960-
val localParams: List[TermParamRef] = tp.paramRefs
961964
val saved = allowed
962965
try
963-
localParams foreach { x => allowed = allowed + x }
966+
tp.paramRefs.foreach(allowed += _)
964967
traverseChildren(tp)
965968
finally allowed = saved
966969
case _ =>

0 commit comments

Comments
 (0)