Skip to content

Commit 988c4c0

Browse files
committed
Adapt tests to shallow capture sets
1 parent 27c9fc5 commit 988c4c0

File tree

8 files changed

+54
-12
lines changed

8 files changed

+54
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Cap extends Retains[*]
33

44
infix type ==> [A, B] = (A => B) retains *
55

6-
type Box[+T <: Top] = [K <: Top] => (T ==> K) => K
6+
type Box[+T <: Top] = ([K <: Top] => (T ==> K) => K) retains T
77

88
def box[T <: Top](x: T): Box[T] =
99
[K <: Top] => (k: T ==> K) => k(x)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:3:2 ------------------------------------------
2+
3 | () => if x == null then y else y // error
3+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
| Found: (() => C) retains x
5+
| Required: () => C
6+
7+
longer explanation available when compiling with `-explain`
8+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:6:2 ------------------------------------------
9+
6 | () => if x == null then y else y // error
10+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11+
| Found: (() => C) retains x
12+
| Required: Any
13+
14+
longer explanation available when compiling with `-explain`
15+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:14:2 -----------------------------------------
16+
14 | f // error
17+
| ^
18+
| Found: (Int => Int) retains x
19+
| Required: Any
20+
21+
longer explanation available when compiling with `-explain`
22+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:23:3 -----------------------------------------
23+
23 | F(22) // error
24+
| ^^^^^
25+
| Found: F retains x
26+
| Required: A
27+
28+
longer explanation available when compiling with `-explain`
29+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:27:40 ----------------------------------------
30+
27 | def m() = if x == null then y else y // error
31+
| ^
32+
| Found: A {...} retains x
33+
| Required: A
34+
35+
longer explanation available when compiling with `-explain`
36+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:32:24 ----------------------------------------
37+
32 | val z2 = h[() => Cap](() => x)(() => C()) // error
38+
| ^^^^^^^
39+
| Found: (() => Cap) retains x
40+
| Required: () => Cap
41+
42+
longer explanation available when compiling with `-explain`

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ def foo() =
3030
val x: C retains * = ???
3131
def h[X <:Top](a: X)(b: X) = a
3232
val z2 = h[() => Cap](() => x)(() => C()) // error
33-
val z3 = h(() => x)(() => C()) // error
33+
val z3 = h[(() => Cap) retains x.type](() => x)(() => C()) // ok
34+
val z4 = h[(() => Cap) retains x.type](() => x)(() => C()) // what was inferred for z3
3435

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ longer explanation available when compiling with `-explain`
2929
-- Error: tests/neg-custom-args/captures/try2.scala:24:28 --------------------------------------------------------------
3030
24 | val a = handle[Exception, CanThrow[Exception]] { // error
3131
| ^^^^^^^^^^^^^^^^^^^
32-
| type argument is not allowed to capture the global capability (canThrow : List[*])
32+
| type argument is not allowed to capture the global capability (canThrow : *)
3333
-- Error: tests/neg-custom-args/captures/try2.scala:36:11 --------------------------------------------------------------
3434
36 | val xx = handle { // error
3535
| ^^^^^^
36-
|inferred type argument ((() => Int) retains canThrow) is not allowed to capture the global capability (canThrow : List[*])
36+
|inferred type argument ((() => Int) retains canThrow) is not allowed to capture the global capability (canThrow : *)
3737
|
3838
|The inferred arguments are: [Exception, ((() => Int) retains canThrow)]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import language.experimental.erasedDefinitions
22
import annotation.ability
33

4-
@ability erased val canThrow: List[*] = ???
4+
@ability erased val canThrow: * = ???
55

66
class CanThrow[E <: Exception] extends Retains[canThrow.type]
77
type Top = Any retains *

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Cap extends Retains[*]
33

44
infix type ==> [A, B] = (A => B) retains *
55

6-
type Box[+T <: Top] = [K <: Top] => (T ==> K) => K
6+
type Box[+T <: Top] = ([K <: Top] => (T ==> K) => K) retains T
77

88
def box[T <: Top](x: T): Box[T] =
99
[K <: Top] => (k: T ==> K) => k(x)
@@ -17,5 +17,5 @@ def lazymap[A <: Top, B <: Top](b: Box[A])(f: A ==> B): (() => Box[B]) retains b
1717
def test[A <: Top, B <: Top] =
1818
def lazymap[A <: Top, B <: Top](b: Box[A])(f: A ==> B) =
1919
() => b[Box[B]]((x: A) => box(f(x)))
20-
val x: (b: Box[A]) => (f: A ==> B) => (() => Box[B]) retains b.type | f.type = lazymap[A, B]
20+
val x: (b: Box[A]) => ((f: A ==> B) => (() => Box[B]) retains b.type | f.type) retains b.type = lazymap[A, B]
2121
()

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class C
22
type Cap = C retains *
33
type Top = Any retains *
4-
def f1(c: Cap): () => C retains c.type = () => c // ok
4+
def f1(c: Cap): (() => c.type) retains c.type = () => c // ok
55

66
def f2: Int =
77
val g: (Boolean => Int) retains * = ???
@@ -18,11 +18,10 @@ def foo() =
1818
val x: C retains * = ???
1919
val y: C retains x.type = x
2020
val x2: (() => C) retains x.type = ???
21-
val y2: () => C retains x.type = x2
21+
val y2: (() => C retains x.type) retains x.type = x2
2222

23-
val z1: () => Cap = f1(x)
23+
val z1: (() => Cap) retains * = f1(x)
2424
def h[X <:Top](a: X)(b: X) = a
2525

2626
val z2 =
2727
if x == null then () => x else () => C()
28-

tests/pos-custom-args/captures/list-encoding.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type Op[T <: Top, C <: Top] =
55
((v: T) => ((s: C) => C) retains *) retains *
66

77
type List[T <: Top] =
8-
[C <: Top] => (op: Op[T, C]) => ((s: C) => C) retains op.type
8+
([C <: Top] => (op: Op[T, C]) => ((s: C) => C) retains op.type) retains T
99

1010
def nil[T <: Top]: List[T] =
1111
[C <: Top] => (op: Op[T, C]) => (s: C) => s

0 commit comments

Comments
 (0)