Skip to content

Commit e8167e4

Browse files
committed
Add some neg tests
1 parent 27126ae commit e8167e4

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

tests/neg/cc-poly-1.check

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- [E057] Type Mismatch Error: tests/neg/cc-poly-1.scala:12:6 ----------------------------------------------------------
2+
12 | f[Any](D()) // error
3+
| ^
4+
| Type argument Any does not conform to upper bound caps.CapSet^
5+
|
6+
| longer explanation available when compiling with `-explain`
7+
-- [E057] Type Mismatch Error: tests/neg/cc-poly-1.scala:13:6 ----------------------------------------------------------
8+
13 | f[String](D()) // error
9+
| ^
10+
| Type argument String does not conform to upper bound caps.CapSet^
11+
|
12+
| longer explanation available when compiling with `-explain`

tests/neg/cc-poly-1.scala

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import language.experimental.captureChecking
2+
import caps.{CapSet, Capability}
3+
4+
object Test:
5+
6+
class C extends Capability
7+
class D
8+
9+
def f[X^](x: D^{X^}): D^{X^} = x
10+
11+
def test(c1: C, c2: C) =
12+
f[Any](D()) // error
13+
f[String](D()) // error

tests/neg/cc-poly-2.check

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- [E007] Type Mismatch Error: tests/neg/cc-poly-2.scala:13:15 ---------------------------------------------------------
2+
13 | f[Nothing](d) // error
3+
| ^
4+
| Found: (d : Test.D^)
5+
| Required: Test.D
6+
|
7+
| longer explanation available when compiling with `-explain`
8+
-- [E007] Type Mismatch Error: tests/neg/cc-poly-2.scala:14:19 ---------------------------------------------------------
9+
14 | f[CapSet^{c1}](d) // error
10+
| ^
11+
| Found: (d : Test.D^)
12+
| Required: Test.D^{c1}
13+
|
14+
| longer explanation available when compiling with `-explain`
15+
-- [E007] Type Mismatch Error: tests/neg/cc-poly-2.scala:16:20 ---------------------------------------------------------
16+
16 | val _: D^{c1} = x // error
17+
| ^
18+
| Found: (x : Test.D^{d})
19+
| Required: Test.D^{c1}
20+
|
21+
| longer explanation available when compiling with `-explain`

tests/neg/cc-poly-2.scala

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import language.experimental.captureChecking
2+
import caps.{CapSet, Capability}
3+
4+
object Test:
5+
6+
class C extends Capability
7+
class D
8+
9+
def f[X^](x: D^{X^}): D^{X^} = x
10+
11+
def test(c1: C, c2: C) =
12+
val d: D^ = D()
13+
f[Nothing](d) // error
14+
f[CapSet^{c1}](d) // error
15+
val x = f(d)
16+
val _: D^{c1} = x // error

0 commit comments

Comments
 (0)