Skip to content

Commit 93cb35c

Browse files
committed
Don't store elements in hidden sets under CCState.collapseFresh
1 parent d2abdfe commit 93cb35c

File tree

6 files changed

+7
-42
lines changed

6 files changed

+7
-42
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ object CaptureSet:
13921392
def addHidden(hidden: HiddenSet, elem: Capability)(using Context): Boolean =
13931393
if hidden.isConst then false
13941394
else
1395-
hidden.add(elem)(using ctx, this)
1395+
if !CCState.collapseFresh then hidden.add(elem)(using ctx, this)
13961396
true
13971397

13981398
/** If root1 and root2 belong to the same binder but have different originalBinders

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,9 @@ object Types extends TypeUtils {
923923
else
924924
val isRefinedMethod = rinfo.isInstanceOf[MethodOrPoly]
925925
val joint = CCState.withCollapsedFresh:
926+
// We have to do a collapseFresh here since `pdenot` will see the class
927+
// view and a fresh in the class will not be able to subsume a
928+
// refinement from outside since level checking would fail.
926929
pdenot.meet(
927930
new JointRefDenotation(NoSymbol, rinfo, Period.allInRun(ctx.runId), pre, isRefinedMethod),
928931
pre,

tests/neg-custom-args/captures/cc-poly-varargs.check

Lines changed: 0 additions & 34 deletions
This file was deleted.

tests/neg-custom-args/captures/cc-this.check

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,3 @@
1515
19 | class C4(val f: () => Int) extends C3 // error
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717
|reference (C4.this.f : () => Int) captured by this self type is not included in the allowed capture set {} of pure base class class C3
18-
-- Error: tests/neg-custom-args/captures/cc-this.scala:33:8 ------------------------------------------------------------
19-
33 | def c3 = c2.y // error
20-
| ^
21-
| Separation failure: method c3's inferred result type C{val x: () => Int}^ hides non-local parameter cc

tests/neg-custom-args/captures/cc-this.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ def test2(using consume cc: Cap) =
3030

3131
def c1 = new C(f)
3232
def c2 = c1
33-
def c3 = c2.y // error
33+
def c3 = c2.y // was error, now OK
3434
val c4: C^ = c3
3535
val _ = c3: C^

tests/neg-custom-args/captures/cc-poly-varargs.scala renamed to tests/pos-custom-args/captures/cc-poly-varargs-original.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ def race[T, Cap^](sources: Source[T, {Cap}]^{Cap}*): Source[T, {Cap}]^{Cap} = ??
88
def either[T1, T2, Cap^](
99
src1: Source[T1, {Cap}]^{Cap},
1010
src2: Source[T2, {Cap}]^{Cap}): Source[Either[T1, T2], {Cap}]^{Cap} =
11-
val left = src1.transformValuesWith(Left(_)) // error
12-
val right = src2.transformValuesWith(Right(_)) // error
11+
val left = src1.transformValuesWith(Left(_)) // was error, now OK
12+
val right = src2.transformValuesWith(Right(_)) // was error, now OK
1313
race(left, right)

0 commit comments

Comments
 (0)