Skip to content

Commit d966bcc

Browse files
committed
Drop deep toCap when checking closures
It seems it's not necessary and it is problematic for soundness.
1 parent 87190ef commit d966bcc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,8 +939,8 @@ class CheckCaptures extends Recheck, SymTransformer:
939939
// which are less intelligible. An example is the line `a = x` in
940940
// neg-custom-args/captures/vars.scala. That's why this code is conditioned.
941941
// to apply only to closures that are not eta expansions.
942-
val res1 = Existential.toCap(res, deep = true) // TODO: why deep = true?
943-
val pt1 = Existential.toCap(pt, deep = true)
942+
val res1 = Existential.toCap(res) // TODO: why deep = true?
943+
val pt1 = Existential.toCap(pt)
944944
// We need to open existentials here in order not to get vars mixed up in them
945945
// We do the proper check with existentials when we are finished with the closure block.
946946
capt.println(i"pre-check closure $expr of type $res1 against $pt1")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ object Existential:
226226
case _ => None
227227

228228
/** Map top-level free existential variables one-to-one to Fresh instances */
229-
def toCap(tp: Type, deep: Boolean = false)(using Context): Type =
229+
def toCap(tp: Type)(using Context): Type =
230230
val subst = new IdempotentCaptRefMap:
231231
val seen = EqHashMap[Annotation, CaptureRef]()
232232
var localBinders: SimpleIdentitySet[MethodType] = SimpleIdentitySet.empty
@@ -238,7 +238,7 @@ object Existential:
238238
case t: MethodType =>
239239
// skip parameters
240240
val saved = localBinders
241-
if t.isFreshBinder && !deep then localBinders = localBinders + t
241+
if t.isFreshBinder then localBinders = localBinders + t
242242
try t.derivedLambdaType(resType = this(t.resType))
243243
finally localBinders = saved
244244
case t: PolyType =>

0 commit comments

Comments
 (0)