aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2014-03-16 13:07:10 +0100
committerodersky <odersky@gmail.com>2014-03-16 13:07:10 +0100
commit027abb4de0710b17ba92499f231d0b0d6467831a (patch)
tree7323ef4304c67037165b8f55277f603b63897916 /tests
parent6a97264962f9e50565a18ba68669c32ca29e90f4 (diff)
parent1554fddc964e71285b0c3860ec3834557fdd2cd4 (diff)
downloaddotty-027abb4de0710b17ba92499f231d0b0d6467831a.tar.gz
dotty-027abb4de0710b17ba92499f231d0b0d6467831a.tar.bz2
dotty-027abb4de0710b17ba92499f231d0b0d6467831a.zip
Merge pull request #69 from odersky/topic/generalize-companions
Bullet-proofing companion objects
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/companions.scala16
-rw-r--r--tests/pos/companions.scala28
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/neg/companions.scala b/tests/neg/companions.scala
new file mode 100644
index 000000000..96b6b4bb6
--- /dev/null
+++ b/tests/neg/companions.scala
@@ -0,0 +1,16 @@
+object companionsNeg {
+
+ def foo() = {
+
+ class C {
+ private val q = 2
+ }
+
+ { object C {
+ private val p = 1
+ println(new C().q)
+ }}
+ }
+
+}
+
diff --git a/tests/pos/companions.scala b/tests/pos/companions.scala
new file mode 100644
index 000000000..6821ad768
--- /dev/null
+++ b/tests/pos/companions.scala
@@ -0,0 +1,28 @@
+object companions {
+
+ def foo() = {
+
+ class C {
+ println(C.p)
+ private val q = 2
+ }
+
+ object C {
+ private val p = 1
+ println(new C().q)
+ }
+ }
+
+}
+object companions2 {
+ def foo() = {
+ {
+ class C {
+ println(C.p)
+ }
+ object C {
+ private val p = 1
+ }
+ }
+ }
+}