Skip to content

Commit e4cc265

Browse files
committed
Drop special handling of functions with pure arguments in Existential.toCap
If existentials are mapped to fresh, it matters where they are opened. Pure or not arguments don't have anything to do with that.
1 parent 748f4a6 commit e4cc265

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,18 +242,10 @@ object Existential:
242242
case _ =>
243243
core
244244

245-
/** Map top-level existentials to `cap`. Do the same for existentials
246-
* in function results if all preceding arguments are known to be always pure.
247-
*/
245+
/** Map top-level existentials to `cap`. */
248246
def toCap(tp: Type)(using Context): Type = tp.dealiasKeepAnnots match
249247
case Existential(boundVar, unpacked) =>
250-
val transformed = unpacked.substParam(boundVar, defn.captureRoot.termRef)
251-
transformed match
252-
case FunctionOrMethod(args, res @ Existential(_, _))
253-
if args.forall(_.isAlwaysPure) =>
254-
transformed.derivedFunctionOrMethod(args, toCap(res))
255-
case _ =>
256-
transformed
248+
unpacked.substParam(boundVar, defn.captureRoot.termRef)
257249
case tp1 @ CapturingType(parent, refs) =>
258250
tp1.derivedCapturingType(toCap(parent), refs)
259251
case tp1 @ AnnotatedType(parent, ann) =>

0 commit comments

Comments
 (0)