Skip to content

Commit 1836fb3

Browse files
committed
Drop @unbox annotation
1 parent 16f86f0 commit 1836fb3

19 files changed

+42
-59
lines changed

library/src/scala/caps.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ import annotation.{experimental, compileTimeOnly, retainsCap}
5252
*/
5353
final class untrackedCaptures extends annotation.StaticAnnotation
5454

55-
/** This should go into annotations. For now it is here, so that we
56-
* can experiment with it quickly between minor releases
57-
*/
58-
final class unbox extends annotation.StaticAnnotation
59-
6055
object unsafe:
6156

6257
extension [T](x: T)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import caps.cap
2-
import caps.unbox
32

43
class Unit
54
object u extends Unit
@@ -18,7 +17,7 @@ def test =
1817

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

21-
def forceWrapper[A](@unbox mx: Wrapper[Unit ->{cap} A]): Wrapper[A] =
20+
def forceWrapper[A](mx: Wrapper[Unit ->{cap} A]): Wrapper[A] =
2221
// Γ ⊢ mx: Wrapper[□ {cap} Unit => A]
2322
// `force` should be typed as ∀(□ {cap} Unit -> A) A, but it can not
2423
strictMap[Unit ->{mx*} A, A](mx)(t => force[A](t)) // error // should work

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:9:33 ----------------------------------------
2-
9 | files.map((f: F) => new Logger(f)) // error, Q: can we make this pass (see #19076)?
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:8:33 ----------------------------------------
2+
8 | files.map((f: F) => new Logger(f)) // error, Q: can we make this pass (see #19076)?
33
| ^
44
| Found: (f : F^)
55
| Required: File^
66
|
77
| longer explanation available when compiling with `-explain`
8-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:12:12 ---------------------------------------
9-
12 | files.map(new Logger(_)) // error, Q: can we improve the error message?
8+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:11:12 ---------------------------------------
9+
11 | files.map(new Logger(_)) // error, Q: can we improve the error message?
1010
| ^^^^^^^^^^^^^
1111
| Found: Logger{val f: (_$1 : File^{files*})}^
1212
| Required: Logger{val f: File^?}^?
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import language.experimental.captureChecking
22
import caps.Capability
3-
import caps.unbox
43

54
trait File extends Capability
65
class Logger(f: File^) extends Capability // <- will work if we remove the extends clause
76

8-
def mkLoggers1[F <: File^](@unbox files: List[F]): List[Logger^] =
7+
def mkLoggers1[F <: File^](files: List[F]): List[Logger^] =
98
files.map((f: F) => new Logger(f)) // error, Q: can we make this pass (see #19076)?
109

11-
def mkLoggers2(@unbox files: List[File^]): List[Logger^] =
10+
def mkLoggers2(files: List[File^]): List[Logger^] =
1211
files.map(new Logger(_)) // error, Q: can we improve the error message?

tests/neg-custom-args/captures/leak-problem-2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import language.experimental.captureChecking
22

33
trait Source[+T]
44

5-
def race[T](@caps.unbox sources: Seq[Source[T]^]): Source[T]^{sources*} = ???
5+
def race[T](sources: Seq[Source[T]^]): Source[T]^{sources*} = ???
66

77
def raceTwo[T](src1: Source[T]^, src2: Source[T]^): Source[T]^{}
88
= race(Seq(src1, src2)) // error
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:22:11 --------------------------------------
2-
22 | cur = (() => f.write()) :: Nil // error
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:21:11 --------------------------------------
2+
21 | cur = (() => f.write()) :: Nil // error
33
| ^^^^^^^^^^^^^^^^^^^^^^^
44
| Found: List[box () ->{f} Unit]
55
| Required: List[box () ->{xs*} Unit]
66
|
77
| longer explanation available when compiling with `-explain`
8-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:33:7 ---------------------------------------
9-
33 | (() => f.write()) :: Nil // error
8+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:32:7 ---------------------------------------
9+
32 | (() => f.write()) :: Nil // error
1010
| ^^^^^^^^^^^^^^^^^^^^^^^
1111
| Found: List[box () ->{f} Unit]
1212
| Required: box List[box () ->{xs*} Unit]^?
@@ -15,40 +15,40 @@
1515
| cannot be included in outer capture set {xs*} of value cur
1616
|
1717
| longer explanation available when compiling with `-explain`
18-
-- Error: tests/neg-custom-args/captures/reaches.scala:38:31 -----------------------------------------------------------
19-
38 | val next: () => Unit = cur.head // error
18+
-- Error: tests/neg-custom-args/captures/reaches.scala:37:31 -----------------------------------------------------------
19+
37 | val next: () => Unit = cur.head // error
2020
| ^^^^^^^^
2121
| The expression's type box () => Unit is not allowed to capture the root capability `cap`.
2222
| This usually means that a capability persists longer than its allowed lifetime.
23-
-- Error: tests/neg-custom-args/captures/reaches.scala:45:35 -----------------------------------------------------------
24-
45 | val next: () => Unit = cur.get.head // error
23+
-- Error: tests/neg-custom-args/captures/reaches.scala:44:35 -----------------------------------------------------------
24+
44 | val next: () => Unit = cur.get.head // error
2525
| ^^^^^^^^^^^^
2626
| The expression's type box () => Unit is not allowed to capture the root capability `cap`.
2727
| This usually means that a capability persists longer than its allowed lifetime.
28-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:53:2 ---------------------------------------
29-
53 | val id: Id[Proc, Proc] = new Id[Proc, () -> Unit] // error
28+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:52:2 ---------------------------------------
29+
52 | val id: Id[Proc, Proc] = new Id[Proc, () -> Unit] // error
3030
| ^
3131
| Found: box () => Unit
3232
| Required: () => Unit
3333
|
3434
| Note that box () => Unit cannot be box-converted to () => Unit
3535
| since at least one of their capture sets contains the root capability `cap`
36-
54 | usingFile: f =>
37-
55 | id(() => f.write())
36+
53 | usingFile: f =>
37+
54 | id(() => f.write())
3838
|
3939
| longer explanation available when compiling with `-explain`
40-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:62:27 --------------------------------------
41-
62 | val f1: File^{id*} = id(f) // error, since now id(f): File^ // error
40+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:61:27 --------------------------------------
41+
61 | val f1: File^{id*} = id(f) // error, since now id(f): File^ // error
4242
| ^^^^^
4343
| Found: File^{f}
4444
| Required: File^{id*}
4545
|
4646
| longer explanation available when compiling with `-explain`
47-
-- Error: tests/neg-custom-args/captures/reaches.scala:61:31 -----------------------------------------------------------
48-
61 | val leaked = usingFile[File^{id*}]: f => // error
47+
-- Error: tests/neg-custom-args/captures/reaches.scala:60:31 -----------------------------------------------------------
48+
60 | val leaked = usingFile[File^{id*}]: f => // error
4949
| ^^^
5050
| id* cannot be tracked since its capture set is empty
51-
-- Error: tests/neg-custom-args/captures/reaches.scala:62:18 -----------------------------------------------------------
52-
62 | val f1: File^{id*} = id(f) // error, since now id(f): File^ // error
51+
-- Error: tests/neg-custom-args/captures/reaches.scala:61:18 -----------------------------------------------------------
52+
61 | val f1: File^{id*} = id(f) // error, since now id(f): File^ // error
5353
| ^^^
5454
| id* cannot be tracked since its capture set is empty

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import caps.unbox
21
class File:
32
def write(): Unit = ???
43

@@ -11,7 +10,7 @@ class Ref[T](init: T):
1110
def get: T = x
1211
def set(y: T) = { x = y }
1312

14-
def runAll0(@unbox xs: List[Proc]): Unit =
13+
def runAll0(xs: List[Proc]): Unit =
1514
var cur: List[() ->{xs*} Unit] = xs
1615
while cur.nonEmpty do
1716
val next: () ->{xs*} Unit = cur.head
@@ -21,7 +20,7 @@ def runAll0(@unbox xs: List[Proc]): Unit =
2120
usingFile: f =>
2221
cur = (() => f.write()) :: Nil // error
2322

24-
def runAll1(@unbox xs: List[Proc]): Unit =
23+
def runAll1(xs: List[Proc]): Unit =
2524
val cur = Ref[List[() ->{xs*} Unit]](xs) // OK, by revised VAR
2625
while cur.get.nonEmpty do
2726
val next: () ->{xs*} Unit = cur.get.head

tests/neg-custom-args/captures/spread-problem.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import language.experimental.captureChecking
22

33
trait Source[+T]
44

5-
def race[T](@caps.unbox sources: (Source[T]^)*): Source[T]^{sources*} = ???
5+
def race[T](sources: (Source[T]^)*): Source[T]^{sources*} = ???
66

77
def raceTwo[T](src1: Source[T]^, src2: Source[T]^): Source[T]^{} =
88
race(Seq(src1, src2)*) // error

tests/pos-custom-args/captures/dep-reach.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import caps.unbox
21
object Test:
32
class C
43
type Proc = () => Unit
54

65
def f(c: C^, d: C^): () ->{c, d} Unit =
7-
def foo(@unbox xs: Proc*): () ->{xs*} Unit =
6+
def foo(xs: Proc*): () ->{xs*} Unit =
87
xs.head
98
val a: () ->{c} Unit = () => ()
109
val b: () ->{d} Unit = () => ()
@@ -13,7 +12,7 @@ object Test:
1312

1413
def g(c: C^, d: C^): () ->{c, d} Unit =
1514

16-
def foo(@unbox xs: Seq[() => Unit]): () ->{xs*} Unit =
15+
def foo(xs: Seq[() => Unit]): () ->{xs*} Unit =
1716
xs.head
1817

1918
val a: () ->{c} Unit = () => ()

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import language.experimental.captureChecking
2-
import caps.unbox
32

43
class List[+A]:
54
def head: A = ???
@@ -8,7 +7,7 @@ class List[+A]:
87
def foreach[U](f: A => U): Unit = ???
98
def nonEmpty: Boolean = ???
109

11-
def runOps(@unbox ops: List[() => Unit]): Unit =
10+
def runOps(ops: List[() => Unit]): Unit =
1211
// See i20156, due to limitation in expressiveness of current system,
1312
// we could map over the list of impure elements. OK with existentials.
1413
ops.foreach(op => op())

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import caps.unbox
21

32
class C
43
def f(xs: List[C^]) =
@@ -22,7 +21,7 @@ extension [A](x: A) def :: (xs: List[A]): List[A] = ???
2221

2322
object Nil extends List[Nothing]
2423

25-
def runAll(@unbox xs: List[Proc]): Unit =
24+
def runAll(xs: List[Proc]): Unit =
2625
var cur: List[() ->{xs*} Unit] = xs // OK, by revised VAR
2726
while cur.nonEmpty do
2827
val next: () ->{xs*} Unit = cur.head

tests/pos/cc-poly-source-capability.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import language.experimental.captureChecking
22
import annotation.experimental
33
import caps.{CapSet, Capability}
4-
import caps.unbox
54

65
@experimental object Test:
76

@@ -18,7 +17,7 @@ import caps.unbox
1817

1918
def allListeners: Set[Listener^{X^}] = listeners
2019

21-
def test1(async1: Async, @unbox others: List[Async]) =
20+
def test1(async1: Async, others: List[Async]) =
2221
val src = Source[CapSet^{async1, others*}]
2322
val lst1 = listener(async1)
2423
val lsts = others.map(listener)

tests/pos/cc-poly-source.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import language.experimental.captureChecking
22
import annotation.experimental
33
import caps.{CapSet, Capability}
4-
import caps.unbox
54

65
@experimental object Test:
76

@@ -25,7 +24,7 @@ import caps.unbox
2524
val ls = src.allListeners
2625
val _: Set[Listener^{lbl1, lbl2}] = ls
2726

28-
def test2(@unbox lbls: List[Label^]) =
27+
def test2(lbls: List[Label^]) =
2928
def makeListener(lbl: Label^): Listener^{lbl} = ???
3029
val listeners = lbls.map(makeListener)
3130
val src = Source[CapSet^{lbls*}]

tests/pos/gears-probem-1.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import language.experimental.captureChecking
2-
import caps.unbox
32

43
trait Future[+T]:
54
def await: T
@@ -17,7 +16,7 @@ class Result[+T, +E]:
1716
case class Err[+E](e: E) extends Result[Nothing, E]
1817
case class Ok[+T](x: T) extends Result[T, Nothing]
1918

20-
extension [T](@unbox fs: Seq[Future[T]^])
19+
extension [T](fs: Seq[Future[T]^])
2120
def awaitAll =
2221
val collector//: Collector[T]{val futures: Seq[Future[T]^{fs*}]}
2322
= Collector(fs)

tests/pos/i13541.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object Z:
66
type Foo[B] = [A] =>> Bar[A, B]
77
trait Bar[A, B]
88

9-
given fooUnit[A: F]: Foo[Unit][A] = ???
9+
given fooUnit: [A: F] => Foo[Unit][A] = ???
1010
//given bar[A: F]: Bar[A, Unit] = ???
1111

1212
def f[A: F](using Foo[Unit][A]): Nothing = ???

tests/pos/i18699.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import language.experimental.captureChecking
2-
import caps.unbox
32

43
trait Cap:
54
def use: Int = 42
65

7-
def test2(@unbox cs: List[Cap^]): Unit =
6+
def test2(cs: List[Cap^]): Unit =
87
val t0: Cap^{cs*} = cs.head // error
98
var t1: Cap^{cs*} = cs.head // error

tests/pos/i20342.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class Repo[EC, E](using defaults: RepoDefaults[EC, E])
22
trait RepoDefaults[EC, E]
33
object RepoDefaults:
4-
inline given genImmutableRepo[E: DbCodec]: RepoDefaults[E, E] = ???
5-
inline given genRepo[EC: DbCodec, E: DbCodec]: RepoDefaults[EC, E] = ???
4+
inline given genImmutableRepo: [E: DbCodec] => RepoDefaults[E, E] = ???
5+
inline given genRepo: [EC: DbCodec, E: DbCodec] => RepoDefaults[EC, E] = ???
66

77
trait DbCodec[E]
88

tests/pos/reach-capability.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import language.experimental.captureChecking
22
import annotation.experimental
33
import caps.Capability
4-
import caps.unbox
54

65
@experimental object Test2:
76

@@ -12,7 +11,7 @@ import caps.unbox
1211

1312
class Listener
1413

15-
def test2(@unbox lbls: List[Label]) =
14+
def test2(lbls: List[Label]) =
1615
def makeListener(lbl: Label): Listener^{lbl} = ???
1716
val listeners = lbls.map(makeListener) // should work
1817

tests/pos/reach-problem.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import language.experimental.captureChecking
2-
import caps.unbox
32

43
class Box[T](items: Seq[T^]):
54
def getOne: T^{items*} = ???
65

76
object Box:
8-
def getOne[T](@unbox items: Seq[T^]): T^{items*} =
7+
def getOne[T](items: Seq[T^]): T^{items*} =
98
val bx = Box(items)
109
bx.getOne
1110
/*

0 commit comments

Comments
 (0)