diff --git a/tests/neg-custom-args/captures/i24667.check b/tests/neg-custom-args/captures/i24667.check new file mode 100644 index 000000000000..8085cd270a29 --- /dev/null +++ b/tests/neg-custom-args/captures/i24667.check @@ -0,0 +1,18 @@ +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i24667.scala:10:18 --------------------------------------- +10 | val _: AnyRef = w // error on this line + | ^ + | Found: (w : O.type) + | Required: AnyRef + | + | Note that capability c is not included in capture set {}. + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i24667.scala:11:22 --------------------------------------- +11 | val _: AnyRef^{c} = w // error on this line, since d is also captured + | ^ + | Found: (w : O.type) + | Required: Object^{c} + | + | Note that capability O is not included in capture set {c}. + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i24667.scala b/tests/neg-custom-args/captures/i24667.scala new file mode 100644 index 000000000000..55c4332b2c66 --- /dev/null +++ b/tests/neg-custom-args/captures/i24667.scala @@ -0,0 +1,13 @@ +import language.experimental.captureChecking + +def foo(c: AnyRef^, d: AnyRef^, e: AnyRef^): Unit = + trait I + object O: + val x = c + def foo = println(d) + + val w: O.type = O // O is not pure + val _: AnyRef = w // error on this line + val _: AnyRef^{c} = w // error on this line, since d is also captured + val _: AnyRef^{c, d} = w // ok +