Skip to content

Commit afcbdcb

Browse files
committed
Rename @unboxed --> @unbox
1 parent 082214e commit afcbdcb

File tree

18 files changed

+39
-37
lines changed

18 files changed

+39
-37
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ class CheckCaptures extends Recheck, SymTransformer:
395395
val refOwner = refSym.owner
396396
val isVisible = isVisibleFromEnv(refOwner)
397397
if !isVisible && c.isReach && refSym.is(Param) && refOwner == env.owner then
398-
if refSym.hasAnnotation(defn.UnboxedAnnot) then
398+
if refSym.hasAnnotation(defn.UnboxAnnot) then
399399
capt.println(i"exempt: $ref in $refOwner")
400400
else
401401
// Reach capabilities that go out of scope have to be approximated
@@ -425,7 +425,7 @@ class CheckCaptures extends Recheck, SymTransformer:
425425
val unboxedParamNames =
426426
meth.rawParamss.flatMap: params =>
427427
params.collect:
428-
case param if param.hasAnnotation(defn.UnboxedAnnot) =>
428+
case param if param.hasAnnotation(defn.UnboxAnnot) =>
429429
param.name
430430
.toSet
431431

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ class Definitions {
10501050
@tu lazy val ExperimentalAnnot: ClassSymbol = requiredClass("scala.annotation.experimental")
10511051
@tu lazy val ThrowsAnnot: ClassSymbol = requiredClass("scala.throws")
10521052
@tu lazy val TransientAnnot: ClassSymbol = requiredClass("scala.transient")
1053-
@tu lazy val UnboxedAnnot: ClassSymbol = requiredClass("scala.caps.unboxed")
1053+
@tu lazy val UnboxAnnot: ClassSymbol = requiredClass("scala.caps.unbox")
10541054
@tu lazy val UncheckedAnnot: ClassSymbol = requiredClass("scala.unchecked")
10551055
@tu lazy val UncheckedStableAnnot: ClassSymbol = requiredClass("scala.annotation.unchecked.uncheckedStable")
10561056
@tu lazy val UncheckedVarianceAnnot: ClassSymbol = requiredClass("scala.annotation.unchecked.uncheckedVariance")

library/src/scala/caps.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ import annotation.{experimental, compileTimeOnly}
3939
*/
4040
final class untrackedCaptures extends annotation.StaticAnnotation
4141

42-
final class unboxed extends annotation.StaticAnnotation
42+
/** This should go into annotations. For now it is here, so that we
43+
* can experiment with it quickly between minor releases
44+
*/
45+
final class unbox extends annotation.StaticAnnotation
4346

4447
object unsafe:
4548

scala2-library-cc/src/scala/collection/mutable/Buffer.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package mutable
1515

1616
import scala.annotation.nowarn
1717
import language.experimental.captureChecking
18-
import caps.unboxed
1918

2019
/** A `Buffer` is a growable and shrinkable `Seq`. */
2120
trait Buffer[A]
@@ -180,11 +179,11 @@ trait IndexedBuffer[A] extends IndexedSeq[A]
180179

181180
override def iterableFactory: SeqFactory[IndexedBuffer] = IndexedBuffer
182181

183-
def flatMapInPlace(@unboxed f: A => IterableOnce[A]^): this.type = {
182+
def flatMapInPlace(f: A => IterableOnce[A]^): this.type = {
184183
// There's scope for a better implementation which copies elements in place.
185184
var i = 0
186185
val s = size
187-
val newElems = new Array[(IterableOnce[A]^{f*})](s)
186+
val newElems = new Array[(IterableOnce[A]^{f})](s)
188187
while (i < s) { newElems(i) = f(this(i)); i += 1 }
189188
clear()
190189
i = 0

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import caps.cap
2-
import caps.unboxed
2+
import caps.unbox
33

44
class Unit
55
object u extends Unit
@@ -18,7 +18,7 @@ def test =
1818

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

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

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.unboxed sources: Seq[Source[T]^]): Source[T]^{sources*} = ???
5+
def race[T](@caps.unbox 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

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import caps.unboxed
1+
import caps.unbox
22
class File:
33
def write(): Unit = ???
44

@@ -11,7 +11,7 @@ class Ref[T](init: T):
1111
def get: T = x
1212
def set(y: T) = { x = y }
1313

14-
def runAll0(@unboxed xs: List[Proc]): Unit =
14+
def runAll0(@unbox xs: List[Proc]): Unit =
1515
var cur: List[() ->{xs*} Unit] = xs
1616
while cur.nonEmpty do
1717
val next: () ->{xs*} Unit = cur.head
@@ -21,7 +21,7 @@ def runAll0(@unboxed xs: List[Proc]): Unit =
2121
usingFile: f =>
2222
cur = (() => f.write()) :: Nil // error
2323

24-
def runAll1(@unboxed xs: List[Proc]): Unit =
24+
def runAll1(@unbox xs: List[Proc]): Unit =
2525
val cur = Ref[List[() ->{xs*} Unit]](xs) // OK, by revised VAR
2626
while cur.get.nonEmpty do
2727
val next: () ->{xs*} Unit = cur.get.head
@@ -78,5 +78,5 @@ def compose1[A, B, C](f: A => B, g: B => C): A ->{f, g} C =
7878
def mapCompose[A](ps: List[(A => A, A => A)]): List[A ->{ps*} A] =
7979
ps.map((x, y) => compose1(x, y)) // error // error
8080

81-
def mapCompose2[A](@unboxed ps: List[(A => A, A => A)]): List[A ->{ps*} A] =
81+
def mapCompose2[A](@unbox ps: List[(A => A, A => A)]): List[A ->{ps*} A] =
8282
ps.map((x, y) => compose1(x, y))

tests/neg/i20503.scala

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

44
class List[+A]:
55
def head: A = ???
@@ -8,7 +8,7 @@ class List[+A]:
88
def foreach[U](f: A => U): Unit = ???
99
def nonEmpty: Boolean = ???
1010

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

tests/neg/leak-problem-unboxed.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import language.experimental.captureChecking
2-
import caps.unboxed
2+
import caps.unbox
33

44
// Some capabilities that should be used locally
55
trait Async:
@@ -9,12 +9,12 @@ def usingAsync[X](op: Async^ => X): X = ???
99

1010
case class Box[+T](get: T)
1111

12-
def useBoxedAsync(@unboxed x: Box[Async^]): Unit =
12+
def useBoxedAsync(@unbox x: Box[Async^]): Unit =
1313
val t0 = x
1414
val t1 = t0.get // ok
1515
t1.read()
1616

17-
def useBoxedAsync1(@unboxed x: Box[Async^]): Unit = x.get.read() // ok
17+
def useBoxedAsync1(@unbox x: Box[Async^]): Unit = x.get.read() // ok
1818

1919
def test(): Unit =
2020

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait Buffer[A]:
1010
val s = 10
1111
// capture checking: we need the copy since we box/unbox on g* on the next line
1212
// TODO: This looks fishy, need to investigate
13-
// Alternative would be to mark `f` as @unboxed. It's not inferred
13+
// Alternative would be to mark `f` as @unbox. It's not inferred
1414
// since `^ appears in a function result, not under a box.
1515
val newElems = new Array[(IterableOnce[A]^{f})](s)
1616
var i = 0

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import caps.unboxed
1+
import caps.unbox
22
object Test:
33
class C
44
type Proc = () => Unit
55

66
def f(c: C^, d: C^): () ->{c, d} Unit =
7-
def foo(@unboxed xs: Proc*): () ->{xs*} Unit =
7+
def foo(@unbox xs: Proc*): () ->{xs*} Unit =
88
xs.head
99
val a: () ->{c} Unit = () => ()
1010
val b: () ->{d} Unit = () => ()
@@ -13,7 +13,7 @@ object Test:
1313

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

16-
def foo(@unboxed xs: Seq[() => Unit]): () ->{xs*} Unit =
16+
def foo(@unbox xs: Seq[() => Unit]): () ->{xs*} Unit =
1717
xs.head
1818

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import caps.unboxed
1+
import caps.unbox
22

33
class C
44
def f(xs: List[C^]) =
@@ -22,7 +22,7 @@ extension [A](x: A) def :: (xs: List[A]): List[A] = ???
2222

2323
object Nil extends List[Nothing]
2424

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

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

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

66
@experimental object Test:
77

@@ -18,7 +18,7 @@ import caps.unboxed
1818

1919
def allListeners: Set[Listener^{X^}] = listeners
2020

21-
def test1(async1: Async, @unboxed others: List[Async]) =
21+
def test1(async1: Async, @unbox others: List[Async]) =
2222
val src = Source[CapSet^{async1, others*}]
2323
val lst1 = listener(async1)
2424
val lsts = others.map(listener)

tests/pos/cc-poly-source.scala

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

66
@experimental object Test:
77

@@ -25,7 +25,7 @@ import caps.unboxed
2525
val ls = src.allListeners
2626
val _: Set[Listener^{lbl1, lbl2}] = ls
2727

28-
def test2(@unboxed lbls: List[Label^]) =
28+
def test2(@unbox lbls: List[Label^]) =
2929
def makeListener(lbl: Label^): Listener^{lbl} = ???
3030
val listeners = lbls.map(makeListener)
3131
val src = Source[CapSet^{lbls*}]

tests/pos/gears-probem-1.scala

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

44
trait Future[+T]:
55
def await: T
@@ -17,7 +17,7 @@ class Result[+T, +E]:
1717
case class Err[+E](e: E) extends Result[Nothing, E]
1818
case class Ok[+T](x: T) extends Result[T, Nothing]
1919

20-
extension [T](@unboxed fs: Seq[Future[T]^])
20+
extension [T](@unbox fs: Seq[Future[T]^])
2121
def awaitAll =
2222
val collector//: Collector[T]{val futures: Seq[Future[T]^{fs*}]}
2323
= Collector(fs)

tests/pos/i18699.scala

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

44
trait Cap:
55
def use: Int = 42
66

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

tests/pos/reach-capability.scala

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

66
@experimental object Test2:
77

@@ -12,7 +12,7 @@ import caps.unboxed
1212

1313
class Listener
1414

15-
def test2(@unboxed lbls: List[Label]) =
15+
def test2(@unbox lbls: List[Label]) =
1616
def makeListener(lbl: Label): Listener^{lbl} = ???
1717
val listeners = lbls.map(makeListener) // should work
1818

tests/pos/reach-problem.scala

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

44
class Box[T](items: Seq[T^]):
55
def getOne: T^{items*} = ???
66

77
object Box:
8-
def getOne[T](@unboxed items: Seq[T^]): T^{items*} =
8+
def getOne[T](@unbox items: Seq[T^]): T^{items*} =
99
val bx = Box(items)
1010
bx.getOne
1111
/*

0 commit comments

Comments
 (0)