Skip to content

Commit f889563

Browse files
committed
check the result of widened capture set inclusion
1 parent dfd077e commit f889563

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -934,32 +934,17 @@ class CheckCaptures extends Recheck, SymTransformer:
934934

935935
private def healCaptureSet(cs: CaptureSet): Unit =
936936
val toInclude = widenParamRefs(cs.elems.toList.filter(!isAllowed(_)).asInstanceOf)
937-
toInclude foreach { cs1 =>
938-
// We omit the check of the result of capture set inclusion here,
939-
// since there are only two possible kinds of errors.
940-
// Both kinds will be detected in other places and tend to
941-
// give better error messages.
942-
//
943-
// The two kinds of errors are:
944-
// - Pushing `*` to a boxed capture set.
945-
// This triggers error reporting registered as the `rootAddedHandler`
946-
// in `CaptureSet`.
947-
// - Failing to include a capture reference in a capture set.
948-
// This is mostly due to the restriction placed by explicit type annotations,
949-
// and should already be reported as a type mismatch during `checkConforms`.
950-
cs1.subCaptures(cs, frozen = false)
951-
}
937+
toInclude.foreach(checkSubset(_, cs, tree.srcPos))
952938

953939
private var allowed: SimpleIdentitySet[TermParamRef] = SimpleIdentitySet.empty
954940

955941
def traverse(tp: Type) =
956942
tp match
957943
case CapturingType(parent, refs) =>
958944
healCaptureSet(refs)
959-
// mapOver(tp)
960-
traverseChildren(parent)
945+
traverse(parent)
961946
case tp @ RefinedType(parent, rname, rinfo: MethodType) if defn.isFunctionType(tp) =>
962-
traverseChildren(rinfo)
947+
traverse(rinfo)
963948
case tp: TermLambda =>
964949
val saved = allowed
965950
try

0 commit comments

Comments
 (0)