diff --git a/tests/neg-custom-args/captures/escaping-local-roots.scala b/tests/neg-custom-args/captures/escaping-local-roots.scala new file mode 100644 index 000000000000..c2b2a187e3b7 --- /dev/null +++ b/tests/neg-custom-args/captures/escaping-local-roots.scala @@ -0,0 +1,19 @@ +import language.experimental.captureChecking + +trait IO: + def use: Unit + +object test1 { + def foo(c: IO^): IO^{cap[foo]} = c // error +} + +def test2 = { + def foo(c: IO^) = // error + def bar: IO^{cap[foo]} = c + bar +} + +object test3 { + def foo(c: IO^): IO^{cap[bar]} = ??? // error + def bar(c: IO^): IO^{cap[foo]} = ??? // error +} diff --git a/tests/neg-custom-args/captures/local-roots-inner-classes.scala b/tests/neg-custom-args/captures/local-roots-inner-classes.scala new file mode 100644 index 000000000000..8459b53b7f0b --- /dev/null +++ b/tests/neg-custom-args/captures/local-roots-inner-classes.scala @@ -0,0 +1,9 @@ +import language.experimental.captureChecking + +class C[T]: + object inner: + val x: T^{cap[C]} = ??? // error + +class C1[T]: + private object inner: + val x: T^{cap[C1]} = ??? // ok