File tree Expand file tree Collapse file tree 6 files changed +60
-13
lines changed
tests/neg-custom-args/captures Expand file tree Collapse file tree 6 files changed +60
-13
lines changed Original file line number Diff line number Diff line change 1212-- Error: tests/neg-custom-args/captures/cc-this.scala:17:8 ------------------------------------------------------------
131317 | 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
Original file line number Diff line number Diff line change 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 -----------------------------------
372 |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`
Original file line number Diff line number Diff line change 11
22class D extends C : // error
3- this : D ^ =>
3+ this : D ^ => // error
Original file line number Diff line number Diff line change 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 ----------------------------------------------
767 | val x = c // error
87 | ^
Original file line number Diff line number Diff line change 11
2- class Err extends Exception : // error
3- self : Err ^ =>
2+ class Err extends Exception :
3+ self : Err ^ => // error
44
55def test (c : Any ^ ) =
66 class Err2 extends Exception :
Original file line number Diff line number Diff line change 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+ ()
You can’t perform that action at this time.
0 commit comments