diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-12-12 15:10:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-12 15:10:01 +0100 |
commit | d34e44e99488e4f91a677ddbc2e8ae6232273456 (patch) | |
tree | 6fa403cdd85cf273072662894a52083c3b86bc81 /test | |
parent | 623f0a72bad9513a154b4a6367c5e215adf769d0 (diff) | |
parent | 9502a061fa007ceb1d4e550fdb386a3645c67b1c (diff) | |
download | scala-d34e44e99488e4f91a677ddbc2e8ae6232273456.tar.gz scala-d34e44e99488e4f91a677ddbc2e8ae6232273456.tar.bz2 scala-d34e44e99488e4f91a677ddbc2e8ae6232273456.zip |
Merge pull request #5550 from retronym/ticket/3772
SI-3772 Fix detection of term-owned companions
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t3772.check | 7 | ||||
-rw-r--r-- | test/files/neg/t3772.scala | 17 | ||||
-rw-r--r-- | test/files/neg/t8002-nested-scope.check | 4 | ||||
-rw-r--r-- | test/files/neg/t8002-nested-scope.scala | 12 | ||||
-rw-r--r-- | test/files/pos/t3772.scala | 8 | ||||
-rw-r--r-- | test/files/pos/t8002-nested-scope.scala | 20 |
6 files changed, 48 insertions, 20 deletions
diff --git a/test/files/neg/t3772.check b/test/files/neg/t3772.check new file mode 100644 index 0000000000..d1ed39d8b6 --- /dev/null +++ b/test/files/neg/t3772.check @@ -0,0 +1,7 @@ +t3772.scala:7: error: value inner is not a member of object CC + CC.inner + ^ +t3772.scala:14: error: value outer is not a member of object CC + CC.outer + ^ +two errors found diff --git a/test/files/neg/t3772.scala b/test/files/neg/t3772.scala new file mode 100644 index 0000000000..cac4932d4a --- /dev/null +++ b/test/files/neg/t3772.scala @@ -0,0 +1,17 @@ +class Test { + def m = { + case class CC(c: Int) + if ("".isEmpty) { + object CC { def inner = 42} + } + CC.inner + } + def n = { + object CC { val outer = 42 } + if ("".isEmpty) { + case class CC(c: Int) + CC(0).c + CC.outer + } + } +} diff --git a/test/files/neg/t8002-nested-scope.check b/test/files/neg/t8002-nested-scope.check new file mode 100644 index 0000000000..f66249e432 --- /dev/null +++ b/test/files/neg/t8002-nested-scope.check @@ -0,0 +1,4 @@ +t8002-nested-scope.scala:8: error: method x in class C cannot be accessed in C + new C().x + ^ +one error found diff --git a/test/files/neg/t8002-nested-scope.scala b/test/files/neg/t8002-nested-scope.scala new file mode 100644 index 0000000000..44704a12b1 --- /dev/null +++ b/test/files/neg/t8002-nested-scope.scala @@ -0,0 +1,12 @@ +class C { + def foo = { + class C { private def x = 0 } + + { + val a = 0 + object C { + new C().x + } + } + } +} diff --git a/test/files/pos/t3772.scala b/test/files/pos/t3772.scala new file mode 100644 index 0000000000..62c433ebd1 --- /dev/null +++ b/test/files/pos/t3772.scala @@ -0,0 +1,8 @@ +class Test { + def m = { + case class C(c: Int) + object C { def xxx = true} + C(42).c + C.xxx + } +} diff --git a/test/files/pos/t8002-nested-scope.scala b/test/files/pos/t8002-nested-scope.scala deleted file mode 100644 index 8ce809e556..0000000000 --- a/test/files/pos/t8002-nested-scope.scala +++ /dev/null @@ -1,20 +0,0 @@ -// This test serves to capture the status quo, but should really -// emit an accessibility error. - -// `Namers#companionSymbolOf` seems too lenient, and currently doesn't -// implement the same-scope checks mentioned: -// -// https://github.com/scala/scala/pull/2816#issuecomment-22555206 -// -class C { - def foo = { - class C { private def x = 0 } - - { - val a = 0 - object C { - new C().x - } - } - } -} |