summaryrefslogtreecommitdiff
path: root/test/files/pos/t3772.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-11-17 12:49:59 +1000
committerJason Zaugg <jzaugg@gmail.com>2016-11-29 15:43:36 +1000
commit37037fe70651eee7a1e8a77a2f8b6e74968836b6 (patch)
tree0b996ec1bc2e6fb84939c07782be6f5116e8553c /test/files/pos/t3772.scala
parent3107532f459d4a66ecd302f0b39b14bd7cf2d248 (diff)
downloadscala-37037fe70651eee7a1e8a77a2f8b6e74968836b6.tar.gz
scala-37037fe70651eee7a1e8a77a2f8b6e74968836b6.tar.bz2
scala-37037fe70651eee7a1e8a77a2f8b6e74968836b6.zip
SI-3772 Fix detection of term-owned companions
Companion detection consults the scopes of enclosing Contexts during typechecking to avoid the cycles that would ensue if we had to look at into the info of enclosing class symbols. For example, this used to typecheck: object CC { val outer = 42 } if ("".isEmpty) { case class CC(c: Int) CC.outer } This logic was not suitably hardened to find companions in exactly the same nesting level. After fixing this problem, a similar problem in `Namer::inCurrentScope` could be solved to be more selective about synthesizing a companion object. In particular, if a manually defined companion trails after the case class, don't create an addiotional synthetic comanpanion object.
Diffstat (limited to 'test/files/pos/t3772.scala')
-rw-r--r--test/files/pos/t3772.scala8
1 files changed, 8 insertions, 0 deletions
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
+ }
+}