Skip to content

Commit 0e89802

Browse files
committed
Test for behavior of path uses ending in pure types
This nails down the current behavior, which we argue is correct.
1 parent 4689288 commit 0e89802

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

tests/neg/i20481.check

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
-- [E007] Type Mismatch Error: tests/neg/i20481.scala:8:14 -------------------------------------------------------------
2+
8 | val c1: A = a // error
3+
| ^
4+
| Found: (a : A^)
5+
| Required: A
6+
|
7+
| Note that capability cap is not included in capture set {}.
8+
|
9+
| where: ^ and cap refer to a fresh root capability in the type of parameter a
10+
|
11+
| longer explanation available when compiling with `-explain`
12+
-- [E007] Type Mismatch Error: tests/neg/i20481.scala:10:16 ------------------------------------------------------------
13+
10 | val c3: A = a.f // error
14+
| ^^^
15+
| Found: (a.f : A^)
16+
| Required: A
17+
|
18+
| Note that capability cap is not included in capture set {}.
19+
|
20+
| where: ^ and cap refer to a fresh root capability in the type of value f
21+
|
22+
| longer explanation available when compiling with `-explain`
23+
-- [E007] Type Mismatch Error: tests/neg/i20481.scala:11:23 ------------------------------------------------------------
24+
11 | val f1: () -> Unit = () => println(a) // error
25+
| ^^^^^^^^^^^^^^^^
26+
| Found: () ->{a} Unit
27+
| Required: () -> Unit
28+
|
29+
| Note that capability a is not included in capture set {}.
30+
|
31+
| longer explanation available when compiling with `-explain`
32+
-- [E007] Type Mismatch Error: tests/neg/i20481.scala:13:23 ------------------------------------------------------------
33+
13 | val f3: () -> Unit = () => println(a.f) // error
34+
| ^^^^^^^^^^^^^^^^^^
35+
| Found: () ->{a.f} Unit
36+
| Required: () -> Unit
37+
|
38+
| Note that capability a.f is not included in capture set {}.
39+
|
40+
| longer explanation available when compiling with `-explain`

tests/neg/i20481.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import language.experimental.captureChecking
2+
3+
class A:
4+
val b: A = this
5+
val f: A^ = this
6+
7+
def test(a: A^) =
8+
val c1: A = a // error
9+
val c2: A = a.b // ok
10+
val c3: A = a.f // error
11+
val f1: () -> Unit = () => println(a) // error
12+
val f2: () -> Unit = () => println(a.b) // ok!
13+
val f3: () -> Unit = () => println(a.f) // error

0 commit comments

Comments
 (0)