summaryrefslogtreecommitdiff
path: root/test/files/run/t8944c.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-11-10 23:48:55 +1000
committerJason Zaugg <jzaugg@gmail.com>2014-11-12 16:25:50 +1000
commitff2cd805111b4fcd39ce7fb1f4bd0268a50faeee (patch)
treeb0bc440231aa8d75f2471a1f4a43174cc0772e71 /test/files/run/t8944c.scala
parent15ae8ddd1cc68bee0b4b38b3830720d422656642 (diff)
downloadscala-ff2cd805111b4fcd39ce7fb1f4bd0268a50faeee.tar.gz
scala-ff2cd805111b4fcd39ce7fb1f4bd0268a50faeee.tar.bz2
scala-ff2cd805111b4fcd39ce7fb1f4bd0268a50faeee.zip
SI-8944 A more resiliant naming scheme for case accessors
Case class parameters that are less that public have an extra accessor method created to ensure universal pattern matchability. See #4081 for more background. Currently, this is given a fresh name based on the parameter name. However, this is fragile and the name can change based on unrelated edits higher up in the source file. This commit switches to a stable naming scheme for these methods. A non-public case field `foo` has a corresponding accessor `foo$access$N`, where `N` is the index of the parameter within the constructor parameter list. The enclosed tests show a case that used to trigger a linkage error under separate compilation that now works; shows that by choosing the `foo$access$1` rather than `foo$1` we don't clash with lambda lifted methods in the class; and shows the names of the accessor methods as seen via Java reflection.
Diffstat (limited to 'test/files/run/t8944c.scala')
-rw-r--r--test/files/run/t8944c.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/files/run/t8944c.scala b/test/files/run/t8944c.scala
new file mode 100644
index 0000000000..95c2143851
--- /dev/null
+++ b/test/files/run/t8944c.scala
@@ -0,0 +1,8 @@
+case class Foo[A](private val ant: Any, elk: Any, private val cat: A*)
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ def pred(name: String) = Set("ant", "elk", "cat").exists(name contains _)
+ println(classOf[Foo[_]].getDeclaredMethods.filter(m => pred(m.getName)).sortBy(_.getName).mkString("\n"))
+ }
+}