Skip to content

Commit 0b9acb3

Browse files
committed
Switch version where separation checking starts to 3.8
3.7 is already on us, so bump by one. Two new tests for separation checking. One i15749a required a change in SepCheck: We need to be able to declare reach capabilities in dependencies. The reach is imply dropped. But we can't sometimes use a normal capability since its capture set might be empty.
1 parent b114ada commit 0b9acb3

17 files changed

+44
-26
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ class SepChecker(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
256256
(formal, arg) <- mt.paramInfos.zip(args)
257257
dep <- formal.captureSet.elems.toList
258258
do
259-
val referred = dep match
259+
val referred = dep.stripReach match
260260
case dep: TermParamRef =>
261261
argMap(dep.binder)(dep.paramNum) :: Nil
262262
case dep: ThisType if dep.cls == fn.symbol.owner =>

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ object Build {
12231223
settings(scala2LibraryBootstrappedSettings).
12241224
settings(
12251225
moduleName := "scala2-library-cc",
1226-
scalacOptions ++= Seq("-Ycheck:all", "-source", "3.7")
1226+
scalacOptions ++= Seq("-Ycheck:all", "-source", "3.8")
12271227
)
12281228

12291229
lazy val scala2LibraryBootstrappedSettings = Seq(

tests/neg-custom-args/captures/box-adapt-cases.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import language.`3.7` // sepchecks on
1+
import language.`3.8` // sepchecks on
22
trait Cap { def use(): Int }
33

44
def test1(): Unit = {

tests/neg-custom-args/captures/depfun-reach.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import language.experimental.captureChecking
22
import caps.cap
3-
import language.`3.7` // sepchecks on
3+
import language.`3.8` // sepchecks on
44
def test(io: Object^, async: Object^) =
55
def compose(op: List[(() ->{cap} Unit, () ->{cap} Unit)]): List[() ->{op*} Unit] =
66
List(() => op.foreach((f,g) => { f(); g() }))

tests/neg-custom-args/captures/existential-mapping.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import language.experimental.captureChecking
2-
import language.`3.7` // sepchecks on
2+
import language.`3.8` // sepchecks on
33
class A
44
class C
55
type Fun[X] = (x: C^) -> X

tests/neg-custom-args/captures/i19330.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import language.`3.7` // sepchecks on
1+
import language.`3.8` // sepchecks on
22
import language.experimental.captureChecking
33

44

tests/neg-custom-args/captures/i21614.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import language.experimental.captureChecking
22
import caps.Capability
33
import caps.use
4-
import language.`3.7` // sepchecks on
4+
import language.`3.8` // sepchecks on
55
trait List[+T]:
66
def map[U](f: T => U): List[U]
77

tests/neg-custom-args/captures/lazyref.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import language.`3.7` // sepchecks on
1+
import language.`3.8` // sepchecks on
22
class CC
33
type Cap = CC^
44

tests/neg-custom-args/captures/outer-var.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import language.`3.7` // sepchecks on
1+
import language.`3.8` // sepchecks on
22
class CC
33
type Cap = CC^
44

tests/neg-custom-args/captures/reaches.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import caps.use; import language.`3.7` // sepchecks on
1+
import caps.use; import language.`3.8` // sepchecks on
22
class File:
33
def write(): Unit = ???
44

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
-- Error: tests/neg-custom-args/captures/reaches2.scala:8:10 -----------------------------------------------------------
2-
8 | ps.map((x, y) => compose1(x, y)) // error // error
3-
| ^
4-
|reference ps* is not included in the allowed capture set {}
5-
|of an enclosing function literal with expected type ((box A ->{ps*} A, box A ->{ps*} A)) -> box (x$0: A^?) ->? A^?
6-
-- Error: tests/neg-custom-args/captures/reaches2.scala:8:13 -----------------------------------------------------------
7-
8 | ps.map((x, y) => compose1(x, y)) // error // error
8-
| ^
9-
|reference ps* is not included in the allowed capture set {}
10-
|of an enclosing function literal with expected type ((box A ->{ps*} A, box A ->{ps*} A)) -> box (x$0: A^?) ->? A^?
1+
-- Error: tests/neg-custom-args/captures/reaches2.scala:10:10 ----------------------------------------------------------
2+
10 | ps.map((x, y) => compose1(x, y)) // error // error // error
3+
| ^
4+
|reference ps* is not included in the allowed capture set {}
5+
|of an enclosing function literal with expected type ((box A ->{ps*} A, box A ->{ps*} A)) -> box (x$0: A^?) ->? A^?
6+
-- Error: tests/neg-custom-args/captures/reaches2.scala:10:13 ----------------------------------------------------------
7+
10 | ps.map((x, y) => compose1(x, y)) // error // error // error
8+
| ^
9+
|reference ps* is not included in the allowed capture set {}
10+
|of an enclosing function literal with expected type ((box A ->{ps*} A, box A ->{ps*} A)) -> box (x$0: A^?) ->? A^?
11+
-- Error: tests/neg-custom-args/captures/reaches2.scala:10:31 ----------------------------------------------------------
12+
10 | ps.map((x, y) => compose1(x, y)) // error // error // error
13+
| ^
14+
| Separation failure: argument of type (x$0: A) ->{y} box A^?
15+
| to method compose1: [A, B, C](f: A => B, g: B => C): A ->{f, g} C
16+
| corresponds to capture-polymorphic formal parameter g of type box A^? => box A^?
17+
| and captures {ps*}, but this capability is also passed separately
18+
| in the first argument with type (x$0: A) ->{x} box A^?.
19+
|
20+
| Capture set of first argument : {x}
21+
| Hidden set of current argument : {y}
22+
| Footprint of first argument : {x, ps*}
23+
| Hidden footprint of current argument : {y, ps*}
24+
| Declared footprint of current argument: {}
25+
| Undeclared overlap of footprints : {ps*}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import language.`3.8` // sepchecks on
2+
13
class List[+A]:
24
def map[B](f: A -> B): List[B] = ???
35

46
def compose1[A, B, C](f: A => B, g: B => C): A ->{f, g} C =
57
z => g(f(z))
68

79
def mapCompose[A](ps: List[(A => A, A => A)]): List[A ->{ps*} A] =
8-
ps.map((x, y) => compose1(x, y)) // error // error
10+
ps.map((x, y) => compose1(x, y)) // error // error // error
911

tests/neg-custom-args/captures/unsound-reach-2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import language.experimental.captureChecking; import language.`3.7` // sepchecks on
1+
import language.experimental.captureChecking; import language.`3.8` // sepchecks on
22
trait Consumer[-T]:
33
def apply(x: T): Unit
44

tests/neg-custom-args/captures/unsound-reach-3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
import language.experimental.captureChecking; import language.`3.7` // sepchecks on
3+
import language.experimental.captureChecking; import language.`3.8` // sepchecks on
44
trait File:
55
def close(): Unit
66

tests/neg-custom-args/captures/unsound-reach-4.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
import language.experimental.captureChecking; import language.`3.7` // sepchecks on
3+
import language.experimental.captureChecking; import language.`3.8` // sepchecks on
44
trait File:
55
def close(): Unit
66

tests/neg-custom-args/captures/vars.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import language.`3.7` // sepchecks on
1+
import language.`3.8` // sepchecks on
22

33
class CC
44
type Cap = CC^

tests/pos-custom-args/captures/i15749a.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import caps.cap
22
import caps.use
3+
import language.`3.8` // sepchecks on
34

45
class Unit
56
object u extends Unit
@@ -13,7 +14,7 @@ def test =
1314
def wrapper[T](x: T): Wrapper[T] = Wrapper:
1415
[X] => (op: T ->{cap} X) => op(x)
1516

16-
def strictMap[A <: Top, B <: Top](mx: Wrapper[A])(f: A ->{cap} B): Wrapper[B] =
17+
def strictMap[A <: Top, B <: Top](mx: Wrapper[A])(f: A ->{cap, mx*} B): Wrapper[B] =
1718
mx.value((x: A) => wrapper(f(x)))
1819

1920
def force[A](thunk: Unit ->{cap} A): A = thunk(u)

0 commit comments

Comments
 (0)