summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-03-25 11:23:59 +0100
committerJason Zaugg <jzaugg@gmail.com>2014-03-25 11:23:59 +0100
commit876590b2be42a77fc23e5c57fc155d5772265be7 (patch)
tree4c7ecb96786ddbcc5ef56619f831299229a1be5e /test
parentdaa77d15dd11f086ea578f05ab29fb18119ec02d (diff)
parent540963f5648f49ea73e1064b0d5185edb1f7884d (diff)
downloadscala-876590b2be42a77fc23e5c57fc155d5772265be7.tar.gz
scala-876590b2be42a77fc23e5c57fc155d5772265be7.tar.bz2
scala-876590b2be42a77fc23e5c57fc155d5772265be7.zip
Merge pull request #3614 from retronym/ticket/8196
SI-8196 Runtime reflection robustness for STATIC impl details
Diffstat (limited to 'test')
-rw-r--r--test/files/run/t8196.check3
-rw-r--r--test/files/run/t8196.scala51
2 files changed, 54 insertions, 0 deletions
diff --git a/test/files/run/t8196.check b/test/files/run/t8196.check
new file mode 100644
index 0000000000..3286c15c91
--- /dev/null
+++ b/test/files/run/t8196.check
@@ -0,0 +1,3 @@
+Scope{
+ final private val f1: Int
+}
diff --git a/test/files/run/t8196.scala b/test/files/run/t8196.scala
new file mode 100644
index 0000000000..e219ac166b
--- /dev/null
+++ b/test/files/run/t8196.scala
@@ -0,0 +1,51 @@
+import scala.reflect.runtime.{ universe => ru }
+
+object Test extends App {
+
+ trait FormTrait {
+
+ val runtimeMirror = ru.runtimeMirror(this.getClass.getClassLoader)
+ val instanceMirror = runtimeMirror.reflect(this)
+ val members = instanceMirror.symbol.typeSignature.members
+ def fields = members.filter(_.typeSignature <:< ru.typeOf[Int])
+ }
+
+ val f = () => {
+
+ class Form1 extends FormTrait {
+ val f1 = 5
+ }
+ val form1 = new Form1
+
+ println(form1.fields)
+
+ val form2 = new FormTrait {
+ val g1 = new Form1
+ }
+
+ form2.g1 // comment this line in order to make the test pass
+ ()
+ }
+
+ val g = () => {
+ // Reported as SI-8195, same root cause
+ trait Form {
+
+ private val runtimeMirror = ru.runtimeMirror(this.getClass.getClassLoader)
+ private val instanceMirror = runtimeMirror.reflect(this)
+ private val members = instanceMirror.symbol.typeSignature.members
+
+ }
+
+ val f1 = new Form {
+ val a = 1
+ }
+
+ val f2 = new Form {
+ val b = f1.a
+ }
+ }
+
+ f()
+ g()
+}