summaryrefslogtreecommitdiff
path: root/test/files/run/t7582-private-within
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-06-16 22:03:07 -0400
committerJason Zaugg <jzaugg@gmail.com>2013-06-16 22:08:41 -0400
commit1391c51a5232834338a21250db722a89498ee6f1 (patch)
tree27702631ca8db21c1f19e3036f2dd0e248e284d2 /test/files/run/t7582-private-within
parentf790662a3eab1e8efce5d4096d0efbae96cf45b4 (diff)
downloadscala-1391c51a5232834338a21250db722a89498ee6f1.tar.gz
scala-1391c51a5232834338a21250db722a89498ee6f1.tar.bz2
scala-1391c51a5232834338a21250db722a89498ee6f1.zip
SI-7582 ClassfileParser: populate privateWithin of Java module class
The `privateWithin` attribute of Java companion module classes was correctly set under joint compilation (ie, when using JavaParser), but not under separate compilation. This commit remedies this. The test covers variety of Java symbols.
Diffstat (limited to 'test/files/run/t7582-private-within')
-rw-r--r--test/files/run/t7582-private-within/JavaPackagePrivate.java8
-rw-r--r--test/files/run/t7582-private-within/Test.scala22
2 files changed, 30 insertions, 0 deletions
diff --git a/test/files/run/t7582-private-within/JavaPackagePrivate.java b/test/files/run/t7582-private-within/JavaPackagePrivate.java
new file mode 100644
index 0000000000..672d19b57e
--- /dev/null
+++ b/test/files/run/t7582-private-within/JavaPackagePrivate.java
@@ -0,0 +1,8 @@
+package pack;
+
+class JavaPackagePrivate {
+ int field = 0;
+ static int staticField = 0;
+ void meth() { }
+ static void staticMeth() { }
+}
diff --git a/test/files/run/t7582-private-within/Test.scala b/test/files/run/t7582-private-within/Test.scala
new file mode 100644
index 0000000000..3d581f063b
--- /dev/null
+++ b/test/files/run/t7582-private-within/Test.scala
@@ -0,0 +1,22 @@
+import scala.tools.partest.DirectTest
+
+// Testing that the `privateWithin` field is correctly populated on all
+// the related symbols (e.g. module class) under separate compilation.
+object Test extends DirectTest {
+ def code = ???
+
+ def show(): Unit = {
+ val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
+ val global = newCompiler("-usejavacp", "-cp", classpath, "-d", testOutput.path)
+ import global._
+ withRun(global) { _ =>
+ def check(sym: Symbol) = {
+ sym.initialize
+ println(f"${sym.accessString}%12s ${sym.accurateKindString} ${sym.name.decode}") // we want to see private[pack] for all of these.
+ }
+ val sym = rootMirror.getRequiredClass("pack.JavaPackagePrivate")
+ val syms = Seq(sym, sym.companionModule, sym.companionModule.moduleClass)
+ (syms ++ syms.flatMap(_.info.decls)).foreach(check)
+ }
+ }
+}