Skip to content

Commit ff7e01c

Browse files
authored
Test case for object captures (#24670)
Closes #24667
1 parent b531c2f commit ff7e01c

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i24667.scala:10:18 ---------------------------------------
2+
10 | val _: AnyRef = w // error on this line
3+
| ^
4+
| Found: (w : O.type)
5+
| Required: AnyRef
6+
|
7+
| Note that capability c is not included in capture set {}.
8+
|
9+
| longer explanation available when compiling with `-explain`
10+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i24667.scala:11:22 ---------------------------------------
11+
11 | val _: AnyRef^{c} = w // error on this line, since d is also captured
12+
| ^
13+
| Found: (w : O.type)
14+
| Required: Object^{c}
15+
|
16+
| Note that capability O is not included in capture set {c}.
17+
|
18+
| longer explanation available when compiling with `-explain`
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+
def foo(c: AnyRef^, d: AnyRef^, e: AnyRef^): Unit =
4+
trait I
5+
object O:
6+
val x = c
7+
def foo = println(d)
8+
9+
val w: O.type = O // O is not pure
10+
val _: AnyRef = w // error on this line
11+
val _: AnyRef^{c} = w // error on this line, since d is also captured
12+
val _: AnyRef^{c, d} = w // ok
13+

0 commit comments

Comments
 (0)