Skip to content

Commit d5cee7c

Browse files
committed
Change to new syntax in pos-custom-args
1 parent 8aa4103 commit d5cee7c

36 files changed

+201
-202
lines changed

tests/pos-custom-args/bounded1.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
// To be revisited
22
class CC
3-
type Cap = {*} CC
3+
type Cap = CC^
44

55
def test(c: Cap) =
6-
class B[X <: {c} Object](x: X):
6+
class B[X <: Object^{c}](x: X):
77
def elem = x
88
def lateElem = () => x
99

1010
def f(x: Int): Int = if c == c then x else 0
1111
val b = new B(f)
1212
val r1 = b.elem
13-
val r1c: {c} Int -> Int = r1
13+
val r1c: Int^{c} -> Int = r1
1414
val r2 = b.lateElem
15-
val r2c: () -> {c} Int -> Int = r2 // was error now OK
15+
val r2c: () -> Int^{c} -> Int = r2 // was error now OK
1616

1717
def test2(c: Cap) =
18-
class B[X <: {*} Any](x: X):
18+
class B[X <: Any^](x: X):
1919
def elem = x
2020
def lateElem = () => x
2121

2222
def f(x: Int): Int = if c == c then x else 0
2323
val b = new B(f)
2424
val r1 = b.elem
25-
val r1c: {c} Int -> Int = r1
25+
val r1c: Int ->{c} Int = r1
2626
val r2 = b.lateElem
27-
val r2c: () -> {c} Int -> Int = r2 // was error now OK
27+
val r2c: () -> Int ->{c} Int = r2 // was error now OK
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
class CC
2-
type Cap = {*} CC
2+
type Cap = CC^
33

44
def test(c: Cap) =
5-
class B[X <: {c} Object](x: X):
5+
class B[X <: Object^{c}](x: X):
66
def elem = x
77
def lateElem = () => x
88

99
def f(x: Int): Int = if c == c then x else 0
1010
val b = new B(f)
1111
val r1 = b.elem
12-
val r1c: {c} Int -> Int = r1
12+
val r1c: Int ->{c} Int = r1
1313
val r2 = b.lateElem
14-
val r2c: {c} () -> {c} Int -> Int = r2
14+
val r2c: () ->{c} Int ->{c} Int = r2

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ def foo(x: => Int): Unit = ()
66

77
def test(c: Cap) =
88
val f = () => { c; 1 }
9-
val _: {c} () -> Int = f
9+
val _: () ->{c} Int = f
1010
val g = () => Box(f)
11-
val _: () -> Box[{f} () -> Int] = g
11+
val _: () -> Box[() ->{f} Int] = g

tests/pos-custom-args/captures/boxmap-paper.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ def map[A, B](c: Cell[A])(f: A => B): Cell[B]
1212
def pureMap[A, B](c: Cell[A])(f: A -> B): Cell[B]
1313
= c[Cell[B]]((x: A) => cell(f(x)))
1414

15-
def lazyMap[A, B](c: Cell[A])(f: A => B): {f} () -> Cell[B]
15+
def lazyMap[A, B](c: Cell[A])(f: A => B): () ->{f} Cell[B]
1616
= () => c[Cell[B]]((x: A) => cell(f(x)))
1717

1818
trait IO:
1919
def print(s: String): Unit
2020

21-
def test(io: {*} IO) =
21+
def test(io: IO^) =
2222

23-
val loggedOne: {io} () -> Int = () => { io.print("1"); 1 }
23+
val loggedOne: () ->{io} Int = () => { io.print("1"); 1 }
2424

25-
val c: Cell[{io} () -> Int]
26-
= cell[{io} () -> Int](loggedOne)
25+
val c: Cell[() ->{io} Int]
26+
= cell[() ->{io} Int](loggedOne)
2727

28-
val g = (f: {io} () -> Int) =>
28+
val g = (f: () ->{io} Int) =>
2929
val x = f(); io.print(" + ")
3030
val y = f(); io.print(s" = ${x + y}")
3131

32-
val r = lazyMap[{io} () -> Int, Unit](c)(f => g(f))
33-
val r2 = lazyMap[{io} () -> Int, Unit](c)(g)
32+
val r = lazyMap[() ->{io} Int, Unit](c)(f => g(f))
33+
val r2 = lazyMap[() ->{io} Int, Unit](c)(g)
3434
val r3 = lazyMap(c)(g)
3535
val _ = r()
3636
val _ = r2()

tests/pos-custom-args/captures/caps-universal.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import annotation.retains
22

33
val foo: Int => Int = x => x
44
val bar: (Int -> Int) @retains(caps.*) = foo
5-
val baz: {*} Int -> Int = bar
5+
val baz: Int => Int = bar
66

77

tests/pos-custom-args/captures/capt-capability.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import annotation.capability
22

33
@capability class Cap
4-
def f1(c: Cap): {c} () -> c.type = () => c // ok
4+
def f1(c: Cap): () ->{c} c.type = () => c // ok
55

66
def f2: Int =
77
val g: Boolean => Int = ???
@@ -17,8 +17,8 @@ def f3: Int =
1717
def foo() =
1818
val x: Cap = ???
1919
val y: Cap = x
20-
val x2: {x} () -> Cap = ???
21-
val y2: {x} () -> Cap = x2
20+
val x2: () ->{x} Cap = ???
21+
val y2: () ->{x} Cap = x2
2222

2323
val z1: () => Cap = f1(x)
2424
def h[X](a: X)(b: X) = a

tests/pos-custom-args/captures/capt-depfun.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ def f(y: Cap, z: Cap): String @retains(caps.*) =
1616
val d = a(g())
1717

1818
val ac: ((x: Cap) -> ID[String @retains(x) -> String @retains(x)]) = ???
19-
val bc: (({y} String) -> {y} String) = ac(y)
20-
val dc: (String -> {y, z} String) = ac(g())
19+
val bc: String^{y} -> String^{y} = ac(y)
20+
val dc: String -> String^{y, z} = ac(g())
2121
c

tests/pos-custom-args/captures/capt-depfun2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ type Cap = C @retains(caps.*)
55
def f(y: Cap, z: Cap) =
66
def g(): C @retains(y, z) = ???
77
val ac: ((x: Cap) -> Array[String @retains(x)]) = ???
8-
val dc: Array[? >: String <: {y, z} String] = ac(g()) // needs to be inferred
8+
val dc: Array[? >: String <: String]^{y, z} = ac(g()) // needs to be inferred
99
val ec = ac(y)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object Test:
22

33
def test() =
4-
val x: {*} Any = "abc"
4+
val x: Any^ = "abc"
55
val y: Object @scala.annotation.retains(x) = ???
66
val z: Object @scala.annotation.retains(x, caps.*) = y: Object @annotation.retains(x)
77

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class C
33
type Cap = C @retains(caps.*)
44

55
def test1() =
6-
val y: {*} String = ""
6+
val y: String^ = ""
77
def x: Object @retains(y) = y
88

99
def test2() =
@@ -13,8 +13,8 @@ def test2() =
1313
z: (() -> Unit) @retains(x)
1414
def z2: (() -> Unit) @retains(y) = y
1515
z2: (() -> Unit) @retains(y)
16-
val p: {*} () -> String = () => "abc"
17-
val q: {p} C = ???
18-
val _ = p: ({p} () -> String)
16+
val p: () => String = () => "abc"
17+
val q: C^{p} = ???
18+
val _ = p: (() ->{p} String)
1919

2020

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@annotation.capability class C
22
object test1:
3-
case class Ref(x: {*} String)
3+
case class Ref(x: String^)
44

55
def test(c: C) =
66
val x1 = Ref("hello")
@@ -14,7 +14,7 @@ object test2:
1414

1515
val pure: () -> Unit = () => ()
1616
val impure: () => Unit = pure
17-
val mixed: {c} () -> Unit = pure
17+
val mixed: () ->{c} Unit = pure
1818
val x = Ref(impure)
1919
val y0 = x.copy(pure)
2020
val yc0: Ref = y0
@@ -25,10 +25,10 @@ object test2:
2525
val yc2: Ref = y2
2626

2727
val x3 = Ref(mixed)
28-
val _: {c} Ref = x3
28+
val _: Ref^{c} = x3
2929
val y3 = x3.copy()
30-
val yc3: {c} Ref = y3
30+
val yc3: Ref^{c} = y3
3131

3232
val y4 = y3 match
3333
case Ref(xx) => xx
34-
val y4c: {x3} () -> Unit = y4
34+
val y4c: () ->{x3} Unit = y4

tests/pos-custom-args/captures/cc-expand.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Test:
99

1010
def test(ct: CT, dt: CT) =
1111

12-
def x0: A -> {ct} B = ???
12+
def x0: A -> B^{ct} = ???
1313

1414
def x1: A -> B @retains(ct) = ???
1515
def x2: A -> B -> C @retains(ct) = ???

tests/pos-custom-args/captures/cc-this.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def eff(using Cap): Unit = ()
55
def test(using Cap) =
66

77
class C(val x: () => Int):
8-
val y: {*} C = this
8+
val y: C^ = this
99

1010
def f = () =>
1111
eff
@@ -14,4 +14,4 @@ def test(using Cap) =
1414
def c1 = new C(f)
1515
def c2 = c1
1616
def c3 = c2.y
17-
val _ = c3: {*} C
17+
val _ = c3: C^

tests/pos-custom-args/captures/compare-refined.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ abstract class LIST[+T]:
22
def map[U](f: T => U): LIST[U] = ???
33

44
class C
5-
type Cap = {*} C
5+
type Cap = C^
66

77
def test(d: Cap) =
8-
val zsc: LIST[{d} Cap -> Unit] = ???
9-
val a4 = zsc.map[{d} Cap -> Unit]((x: {d} Cap -> Unit) => x)
10-
val a5 = zsc.map[{d} Cap -> Unit](identity[{d} Cap -> Unit])
11-
val a6 = zsc.map(identity[{d} Cap -> Unit])
8+
val zsc: LIST[Cap ->{d} Unit] = ???
9+
val a4 = zsc.map[Cap ->{d} Unit]((x: Cap ->{d} Unit) => x)
10+
val a5 = zsc.map[Cap ->{d} Unit](identity[Cap ->{d} Unit])
11+
val a6 = zsc.map(identity[Cap ->{d} Unit])
1212
val a7 = zsc.map(identity)

tests/pos-custom-args/captures/curried-shorthands.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ object Test:
1010
val f3 = (f: Int => Int) =>
1111
println(f(3))
1212
(xs: List[Int]) => xs.map(_ + 1)
13-
val f3c: (Int => Int) -> {} List[Int] -> List[Int] = f3
13+
val f3c: (Int => Int) -> List[Int] ->{} List[Int] = f3
1414

1515
class LL[A]:
16-
def drop(n: Int): {this} LL[A] = ???
16+
def drop(n: Int): LL[A]^{this} = ???
1717

1818
def test(ct: CanThrow[Exception]) =
19-
def xs: {ct} LL[Int] = ???
19+
def xs: LL[Int]^{ct} = ???
2020
val ys = xs.drop(_)
21-
val ysc: Int -> {ct} LL[Int] = ys
21+
val ysc: Int -> LL[Int]^{ct} = ys
2222

2323

2424

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ object test1:
66
class File:
77
def write(x: String): Unit = ???
88

9-
class Service(f: {*} File):
9+
class Service(f: File^):
1010
def log = f.write("log")
1111

12-
def withFile[T](op: (f: {*} File) => T): T =
12+
def withFile[T](op: (f: File^) => T): T =
1313
op(new File)
1414

1515
def test =
@@ -24,10 +24,10 @@ object test2:
2424
def write(x: String): Unit = ???
2525

2626
class Service(io: IO):
27-
var file: {io} File = uninitialized
27+
var file: File^{io} = uninitialized
2828
def log = file.write("log")
2929

30-
def withFile[T](io: IO)(op: (f: {io} File) => T): T =
30+
def withFile[T](io: IO)(op: (f: File^{io}) => T): T =
3131
op(new File)
3232

3333
def test(io: IO) =
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/** Concrete collection type: View */
2-
trait View[+A] extends Itable[A], ILike[A, [X] =>> {*} View[X]]:
3-
override def fromIterable[B](c: {*} Itable[B]): {c} View[B] = ???
2+
trait View[+A] extends Itable[A], ILike[A, [X] =>> View[X]^]:
3+
override def fromIterable[B](c: Itable[B]^): View[B]^{c} = ???
44

55
trait IPolyTransforms[+A, +C[A]] extends Any:
6-
def fromIterable[B](coll: {*} Itable[B]): C[B]
6+
def fromIterable[B](coll: Itable[B]^): C[B]
77

8-
trait ILike[+A, +C[X] <: {*} Itable[X]] extends IPolyTransforms[A, C]
8+
trait ILike[+A, +C[X] <: Itable[X]^] extends IPolyTransforms[A, C]
99

1010
/** Base trait for generic collections */
11-
trait Itable[+A] extends ItableOnce[A] with ILike[A, {*} Itable]
11+
trait Itable[+A] extends ItableOnce[A] with ILike[A, Itable^]
1212

1313
/** Iterator can be used only once */
1414
trait ItableOnce[+A] {
15-
this: {*} ItableOnce[A] =>
16-
def iterator: {this} Iterator[A]
15+
this: ItableOnce[A]^ =>
16+
def iterator: Iterator[A]^{this}
1717
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ trait Cap { def use(): Int }
22
type Id[X] = [T] -> (op: X => T) -> T
33
def mkId[X](x: X): Id[X] = [T] => (op: X => T) => op(x)
44

5-
def withCap[X](op: ({*} Cap) => X): X = {
6-
val cap: {*} Cap = new Cap { def use() = { println("cap is used"); 0 } }
5+
def withCap[X](op: (Cap^) => X): X = {
6+
val cap: Cap^ = new Cap { def use() = { println("cap is used"); 0 } }
77
val result = op(cap)
88
result
99
}
1010

11-
def leaking(c: {*} Cap): Id[{c} Cap] = mkId(c)
11+
def leaking(c: Cap^): Id[Cap^{c}] = mkId(c)
1212

1313
def test =
1414
val bad = withCap(leaking)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Test {
1717

1818
@capability
1919
class CpsTransform[F[_]] {
20-
def await[T](ft: F[T]): { this } T = ???
20+
def await[T](ft: F[T]): T^{ this } = ???
2121
}
2222

2323
transparent inline def cpsAsync[F[_]](using m:CpsMonad[F]) =
@@ -27,7 +27,7 @@ object Test {
2727
def apply[A](expr: (CpsTransform[F], C) ?=> A): F[A] = ???
2828
}
2929

30-
def asyncPlus[F[_]](a:Int, b:F[Int])(using cps: CpsTransform[F]): { cps } Int =
30+
def asyncPlus[F[_]](a:Int, b:F[Int])(using cps: CpsTransform[F]): Int^{ cps } =
3131
a + (cps.await(b).asInstanceOf[Int])
3232

3333
def testExample1Future(): Unit =
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
@annotation.capability class Cap
22

33
class LazyRef[T](val elem: () => T):
4-
val get: {elem} () -> T = elem
5-
def map[U](f: T => U): {f, this} LazyRef[U] =
4+
val get: () ->{elem} T = elem
5+
def map[U](f: T => U): LazyRef[U]^{f, this} =
66
new LazyRef(() => f(elem()))
77

8-
def map[A, B](ref: {*} LazyRef[A], f: A => B): {f, ref} LazyRef[B] =
8+
def map[A, B](ref: LazyRef[A]^, f: A => B): LazyRef[B]^{f, ref} =
99
new LazyRef(() => f(ref.elem()))
1010

1111
def main(io: Cap) = {
12-
def mapd[A, B]: ({io} LazyRef[A], A => B) => {*} LazyRef[B] =
12+
def mapd[A, B]: (LazyRef[A]^{io}, A => B) => LazyRef[B]^ =
1313
(ref1, f1) => map[A, B](ref1, f1)
1414
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package cctest
22

33
abstract class Iterator[T]:
4-
thisIterator: {*} Iterator[T] =>
4+
thisIterator: Iterator[T]^ =>
55

66
def hasNext: Boolean
77
def next: T
8-
def map(f: {*} T => T): {f, this} Iterator[T] = new Iterator:
8+
def map(f: T => T): Iterator[T]^{f, this} = new Iterator:
99
def hasNext = thisIterator.hasNext
1010
def next = f(thisIterator.next)
1111
end Iterator
1212

1313
class C
14-
type Cap = {*} C
14+
type Cap = C^
1515

16-
def map[T, U](it: {*} Iterator[T], f: {*} T => U): {it, f} Iterator[U] = new Iterator:
16+
def map[T, U](it: Iterator[T]^, f: T^ => U): Iterator[U]^{it, f} = new Iterator:
1717
def hasNext = it.hasNext
1818
def next = f(it.next)
1919

0 commit comments

Comments
 (0)