Skip to content

Commit e22744d

Browse files
committed
Add sealed refs test and fix check files of other tests
1 parent f4066c0 commit e22744d

File tree

6 files changed

+60
-13
lines changed

6 files changed

+60
-13
lines changed

tests/neg-custom-args/captures/cc-this.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
-- Error: tests/neg-custom-args/captures/cc-this.scala:17:8 ------------------------------------------------------------
1313
17 | class C4(val f: () => Int) extends C3 // error
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15-
| reference (C4.this.f : () => Int) is not included in the allowed capture set {} of pure base class class C3
15+
|reference (C4.this.f : () => Int) captured by this self type is not included in the allowed capture set {} of pure base class class C3
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11

2-
-- Error: tests/neg-custom-args/captures/cc-this2/D_2.scala:2:6 --------------------------------------------------------
2+
-- Error: tests/neg-custom-args/captures/cc-this2/D_2.scala:3:8 --------------------------------------------------------
3+
3 | this: D^ => // error
4+
| ^^
5+
|reference (caps.cap : caps.Cap) captured by this self type is not included in the allowed capture set {} of pure base class class C
6+
-- [E058] Type Mismatch Error: tests/neg-custom-args/captures/cc-this2/D_2.scala:2:6 -----------------------------------
37
2 |class D extends C: // error
4-
|^
5-
|reference (caps.cap : caps.Cap) is not included in the allowed capture set {} of pure base class class C
6-
3 | this: D^ =>
8+
| ^
9+
| illegal inheritance: self type D^ of class D does not conform to self type C
10+
| of parent class C
11+
|
12+
| longer explanation available when compiling with `-explain`
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22
class D extends C: // error
3-
this: D^ =>
3+
this: D^ => // error

tests/neg-custom-args/captures/exception-definitions.check

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
-- Error: tests/neg-custom-args/captures/exception-definitions.scala:2:6 -----------------------------------------------
2-
2 |class Err extends Exception: // error
3-
|^
4-
|reference (caps.cap : caps.Cap) is not included in the allowed capture set {} of pure base class class Throwable
5-
3 | self: Err^ =>
1+
-- Error: tests/neg-custom-args/captures/exception-definitions.scala:3:8 -----------------------------------------------
2+
3 | self: Err^ => // error
3+
| ^^^^
4+
|reference (caps.cap : caps.Cap) captured by this self type is not included in the allowed capture set {} of pure base class class Throwable
65
-- Error: tests/neg-custom-args/captures/exception-definitions.scala:7:12 ----------------------------------------------
76
7 | val x = c // error
87
| ^

tests/neg-custom-args/captures/exception-definitions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
class Err extends Exception: // error
3-
self: Err^ =>
2+
class Err extends Exception:
3+
self: Err^ => // error
44

55
def test(c: Any^) =
66
class Err2 extends Exception:
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
class Ref[sealed A](init: A):
2+
this: Ref[A]^ =>
3+
private var x: A = init
4+
def get: A = x
5+
def set(x: A): Unit = this.x = x
6+
7+
class It[X]:
8+
this: It[X]^ =>
9+
10+
def f1[B1](x: B1, next: B1 -> B1) =
11+
var r = x // ok
12+
r = next(x)
13+
r
14+
15+
def f2[B2](x: B2, next: B2 -> B2) =
16+
val r = Ref[B2](x) // error
17+
r.set(next(x))
18+
r.get
19+
20+
def g[sealed B](x: B, next: B -> B) =
21+
val r = Ref[B](x) // ok
22+
r.set(next(x))
23+
r.get
24+
25+
import annotation.unchecked.uncheckedCaptures
26+
27+
def h[B](x: B, next: B -> B) =
28+
val r = Ref[B @uncheckedCaptures](x) // ok
29+
r.set(next(x))
30+
r.get
31+
32+
def f3[B](x: B, next: B -> B) =
33+
val r: Ref[B^{cap[f3]}] = Ref[B^{cap[f3]}](x) // error
34+
r.set(next(x))
35+
val y = r.get
36+
()
37+
38+
def f4[B](x: B, next: B -> B) =
39+
val r: Ref[B]^{cap[f4]} = Ref[B](x) // error
40+
r.set(next(x))
41+
val y = r.get
42+
()

0 commit comments

Comments
 (0)