Skip to content

Commit

Permalink
Require -source future for separation checking being turned on
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Jan 10, 2025
1 parent a210cb8 commit 498f43d
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 40 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/cc/CaptureOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object ccConfig:
Feature.sourceVersion.stable != SourceVersion.`3.5`

def useFresh(using Context): Boolean =
Feature.sourceVersion.stable.isAtLeast(SourceVersion.`3.6`)
Feature.sourceVersion.stable.isAtLeast(SourceVersion.`future`)

end ccConfig

Expand Down
12 changes: 6 additions & 6 deletions tests/neg-custom-args/captures/box-adapt-cases.check
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/box-adapt-cases.scala:7:10 -------------------------------
7 | x.value(cap => cap.use()) // error, was OK
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/box-adapt-cases.scala:8:10 -------------------------------
8 | x.value(cap => cap.use()) // error, was OK
| ^^^^^^^^^^^^^^^^
| Found: (cap: box Cap^?) => Int
| Required: (cap: box Cap^) ->{fresh} Int
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/box-adapt-cases.scala:14:10 ------------------------------
14 | x.value(cap => cap.use()) // error
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/box-adapt-cases.scala:15:10 ------------------------------
15 | x.value(cap => cap.use()) // error
| ^^^^^^^^^^^^^^^^
| Found: (cap: box Cap^?) ->{io} Int
| Required: (cap: box Cap^{io}) -> Int
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/box-adapt-cases.scala:28:10 ------------------------------
28 | x.value(cap => cap.use()) // error
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/box-adapt-cases.scala:29:10 ------------------------------
29 | x.value(cap => cap.use()) // error
| ^^^^^^^^^^^^^^^^
| Found: (cap: box Cap^?) ->{io, fs} Int
| Required: (cap: box Cap^{io, fs}) ->{io} Int
Expand Down
1 change: 1 addition & 0 deletions tests/neg-custom-args/captures/box-adapt-cases.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import language.future // sepchecks on
trait Cap { def use(): Int }

def test1(): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/depfun-reach.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import language.experimental.captureChecking
import caps.cap

import language.future // sepchecks on
def test(io: Object^, async: Object^) =
def compose(op: List[(() ->{cap} Unit, () ->{cap} Unit)]): List[() ->{op*} Unit] =
List(() => op.foreach((f,g) => { f(); g() }))
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/existential-mapping.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import language.experimental.captureChecking

import language.future // sepchecks on
class A
class C
type Fun[X] = (x: C^) -> X
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/filevar-expanded.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import language.experimental.captureChecking
import language.experimental.modularity
import compiletime.uninitialized

import language.future // sepchecks on
object test1:
class File:
def write(x: String): Unit = ???
Expand Down
4 changes: 2 additions & 2 deletions tests/neg-custom-args/captures/i19330.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


import language.future // sepchecks on
import language.experimental.captureChecking


trait Logger
def usingLogger[T](op: Logger^ => T): T = ???

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/i21614.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import language.experimental.captureChecking
import caps.Capability
import caps.use

import language.future // sepchecks on
trait List[+T]:
def map[U](f: T => U): List[U]

Expand Down
20 changes: 10 additions & 10 deletions tests/neg-custom-args/captures/lazyref.check
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:19:28 --------------------------------------
19 | val ref1c: LazyRef[Int] = ref1 // error
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:20:28 --------------------------------------
20 | val ref1c: LazyRef[Int] = ref1 // error
| ^^^^
| Found: (ref1 : LazyRef[Int]{val elem: () ->{cap1} Int}^{cap1})
| Required: LazyRef[Int]
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:21:35 --------------------------------------
21 | val ref2c: LazyRef[Int]^{cap2} = ref2 // error
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:22:35 --------------------------------------
22 | val ref2c: LazyRef[Int]^{cap2} = ref2 // error
| ^^^^
| Found: LazyRef[Int]{val elem: () ->{ref2*} Int}^{ref2}
| Required: LazyRef[Int]^{cap2}
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:23:35 --------------------------------------
23 | val ref3c: LazyRef[Int]^{ref1} = ref3 // error
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:24:35 --------------------------------------
24 | val ref3c: LazyRef[Int]^{ref1} = ref3 // error
| ^^^^
| Found: LazyRef[Int]{val elem: () ->{ref3*} Int}^{ref3}
| Required: LazyRef[Int]^{ref1}
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:25:35 --------------------------------------
25 | val ref4c: LazyRef[Int]^{cap1} = ref4 // error
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:26:35 --------------------------------------
26 | val ref4c: LazyRef[Int]^{cap1} = ref4 // error
| ^^^^
| Found: LazyRef[Int]{val elem: () ->{ref4*} Int}^{ref4}
| Required: LazyRef[Int]^{cap1}
|
| longer explanation available when compiling with `-explain`
-- Error: tests/neg-custom-args/captures/lazyref.scala:24:55 -----------------------------------------------------------
24 | val ref4 = (if cap1 == cap2 then ref1 else ref2).map(g) // error: separation failure
-- Error: tests/neg-custom-args/captures/lazyref.scala:25:55 -----------------------------------------------------------
25 | val ref4 = (if cap1 == cap2 then ref1 else ref2).map(g) // error: separation failure
| ^
|Separation failure: argument of type (x: Int) ->{cap2} Int
|to method map: [U](f: T => U): LazyRef[U]^{f, LazyRef.this}
Expand Down
1 change: 1 addition & 0 deletions tests/neg-custom-args/captures/lazyref.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import language.future // sepchecks on
class CC
type Cap = CC^

Expand Down
20 changes: 10 additions & 10 deletions tests/neg-custom-args/captures/outer-var.check
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:11:8 -------------------------------------
11 | x = q // error
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:12:8 -------------------------------------
12 | x = q // error
| ^
| Found: (q : () => Unit)
| Required: () ->{p, q²} Unit
Expand All @@ -8,15 +8,15 @@
| q² is a parameter in method test
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:12:9 -------------------------------------
12 | x = (q: Proc) // error
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:13:9 -------------------------------------
13 | x = (q: Proc) // error
| ^^^^^^^
| Found: () => Unit
| Required: () ->{p, q} Unit
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:13:9 -------------------------------------
13 | y = (q: Proc) // error
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:14:9 -------------------------------------
14 | y = (q: Proc) // error
| ^^^^^^^
| Found: () => Unit
| Required: () ->{p} Unit
Expand All @@ -25,8 +25,8 @@
| cannot be included in capture set {p} of variable y
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:14:8 -------------------------------------
14 | y = q // error, was OK under unsealed
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:15:8 -------------------------------------
15 | y = q // error, was OK under unsealed
| ^
| Found: (q : () => Unit)
| Required: () ->{p} Unit
Expand All @@ -35,8 +35,8 @@
| cannot be included in outer capture set {p}
|
| longer explanation available when compiling with `-explain`
-- Error: tests/neg-custom-args/captures/outer-var.scala:16:57 ---------------------------------------------------------
16 | var finalizeActions = collection.mutable.ListBuffer[() => Unit]() // error, was OK under unsealed
-- Error: tests/neg-custom-args/captures/outer-var.scala:17:57 ---------------------------------------------------------
17 | var finalizeActions = collection.mutable.ListBuffer[() => Unit]() // error, was OK under unsealed
| ^^^^^^^^^^
| Type variable A of object ListBuffer cannot be instantiated to box () => Unit since
| that type captures the root capability `cap`.
1 change: 1 addition & 0 deletions tests/neg-custom-args/captures/outer-var.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import language.future // sepchecks on
class CC
type Cap = CC^

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/reaches.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import caps.use
import caps.use; import language.future // sepchecks on
class File:
def write(): Unit = ???

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/sep-compose.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import caps.cap

import language.future // sepchecks on
def seq1(x: () => Unit, y: () ->{x, cap} Unit): Unit =
x(); y()

Expand Down
1 change: 1 addition & 0 deletions tests/neg-custom-args/captures/sepchecks.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import caps.Mutable
import caps.cap
import language.future // sepchecks on

trait Rdr[T]:
def get: T
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/unsound-reach-2.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import language.experimental.captureChecking
import language.experimental.captureChecking; import language.future // sepchecks on
trait Consumer[-T]:
def apply(x: T): Unit

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/unsound-reach-3.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


import language.experimental.captureChecking
import language.experimental.captureChecking; import language.future // sepchecks on
trait File:
def close(): Unit

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/unsound-reach-4.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


import language.experimental.captureChecking
import language.experimental.captureChecking; import language.future // sepchecks on
trait File:
def close(): Unit

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/unsound-reach.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import language.experimental.captureChecking
import language.experimental.captureChecking; import language.future // sepchecks on
trait File:
def close(): Unit

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/vars.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

import language.future // sepchecks on

class CC
type Cap = CC^
Expand Down
1 change: 1 addition & 0 deletions tests/pos-custom-args/captures/sep-compose.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import caps.cap
import language.future // sepchecks on

def seq1(x: () => Unit, y: () ->{x, cap} Unit): Unit =
x(); y()
Expand Down
1 change: 1 addition & 0 deletions tests/pos-custom-args/captures/sep-eq.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import caps.Mutable
import caps.cap
import language.future // sepchecks on

extension (x: Object^)
infix def eql (y: Object^{x, cap}): Boolean = x eq y
Expand Down

0 comments on commit 498f43d

Please sign in to comment.