summaryrefslogtreecommitdiff
path: root/test/pending/neg/t1800.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/pending/neg/t1800.scala')
-rw-r--r--test/pending/neg/t1800.scala28
1 files changed, 0 insertions, 28 deletions
diff --git a/test/pending/neg/t1800.scala b/test/pending/neg/t1800.scala
deleted file mode 100644
index eebbbad9c7..0000000000
--- a/test/pending/neg/t1800.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-object ObjectHolder {
- private[ObjectHolder] class PrivateObject
- def getPrivateObject = new PrivateObject
-}
-
-object Test {
- def main(args: Array[String]) {
- // compiler error: class PrivateObject cannot be accessed
- // in object test.ObjectHolder
- val a: ObjectHolder.PrivateObject = ObjectHolder.getPrivateObject
-
- // works fine
- val b = ObjectHolder.getPrivateObject
- println(b.getClass)
- }
-}
-/*
-When declaring objects as private[package/object] or protected[package/object] it is possible to leak out references to these objects into the public api (can be desirable, this in itself is not a problem).
-
-When users of the api receive such private object via a function call, they can create a variable to reference the private object using inferred typing:
-
-val b = getPrivateObject()
-
-However they cannot create such variable using declared typing:
-
-val a: PrivateObject? = getPrivateObject()
-
-The line above will generate a compiler error: "class PrivateObject? cannot be accessed". Which makes sense, because PrivateObject? was declared private. But in this case inferred typing should not work either, otherwise the behaviors of inferred typing and declared typing become inconsistent. */