Skip to content

Commit ce3d243

Browse files
committed
Always create FreshCap instances even if separation checking is off
1 parent dff27e7 commit ce3d243

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

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

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ object Capabilities:
155155

156156
object FreshCap:
157157
def apply(origin: Origin)(using Context): FreshCap | GlobalCap.type =
158-
if ccConfig.useSepChecks then FreshCap(ctx.owner, origin)
159-
else GlobalCap
158+
FreshCap(ctx.owner, origin)
160159

161160
/** A root capability associated with a function type. These are conceptually
162161
* existentially quantified over the function's result type.
@@ -716,14 +715,12 @@ object Capabilities:
716715
* the map being installed for future use.
717716
*/
718717
def capToFresh(tp: Type, origin: Origin)(using Context): Type =
719-
if ccConfig.useSepChecks then
720-
ccState.withoutMappedFutureElems:
721-
CapToFresh(origin)(tp)
722-
else tp
718+
ccState.withoutMappedFutureElems:
719+
CapToFresh(origin)(tp)
723720

724721
/** Maps fresh to cap */
725722
def freshToCap(tp: Type)(using Context): Type =
726-
if ccConfig.useSepChecks then CapToFresh(Origin.Unknown).inverse(tp) else tp
723+
CapToFresh(Origin.Unknown).inverse(tp)
727724

728725
/** Map top-level free existential variables one-to-one to Fresh instances */
729726
def resultToFresh(tp: Type, origin: Origin)(using Context): Type =
@@ -808,17 +805,14 @@ object Capabilities:
808805
case c @ ResultCap(`mt`) =>
809806
// do a reverse getOrElseUpdate on `seen` to produce the
810807
// `Fresh` assosicated with `t`
811-
if !ccConfig.useSepChecks then
812-
FreshCap(Origin.Unknown) // warning: this can cause cycles
813-
else
814-
val primary = c.primaryResultCap
815-
primary.origin match
816-
case GlobalCap =>
817-
val fresh = FreshCap(Origin.Unknown)
818-
primary.setOrigin(fresh)
819-
fresh
820-
case origin: FreshCap =>
821-
origin
808+
val primary = c.primaryResultCap
809+
primary.origin match
810+
case GlobalCap =>
811+
val fresh = FreshCap(Origin.Unknown)
812+
primary.setOrigin(fresh)
813+
fresh
814+
case origin: FreshCap =>
815+
origin
822816
case _ =>
823817
super.mapCapability(c, deep)
824818

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import language.experimental.captureChecking
2+
trait File
3+
def usingFile[R](op: File^ => R): R = op(new File {})
4+
def id(x: File^): File^{x} = x
5+
def test1(): Unit =
6+
val op: File^ -> File^ = id // error, this should be disallowed
7+
val g: File^ -> File^{op*} = op // otherwise we can brand arbitrary File as simply capturing op*

0 commit comments

Comments
 (0)