aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/leaks.scala7
-rw-r--r--tests/pos/leaks.scala17
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/neg/leaks.scala b/tests/neg/leaks.scala
new file mode 100644
index 000000000..bb81d8cd2
--- /dev/null
+++ b/tests/neg/leaks.scala
@@ -0,0 +1,7 @@
+class Outer {
+ private val x: Int = 1
+
+ class Inner {
+ def foo: x.type = x // error: non-private method foo refers to private value x in its type signature
+ }
+}
diff --git a/tests/pos/leaks.scala b/tests/pos/leaks.scala
new file mode 100644
index 000000000..dbb47d75a
--- /dev/null
+++ b/tests/pos/leaks.scala
@@ -0,0 +1,17 @@
+class Outer1 {
+ private val x: Int = 1
+
+ private class Inner {
+ def foo: x.type = x // OK
+ }
+}
+
+object Outer2 {
+ private val x: Int = 1
+}
+
+class Outer2 {
+ private class Inner {
+ def foo: Outer2.x.type = Outer2.x // OK
+ }
+}