summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-01-31 12:12:23 +0100
committerEugene Burmako <xeno.by@gmail.com>2012-02-01 23:10:55 +0100
commit1e0707786b118e3e33379e7acdc75306b45e6547 (patch)
tree2569832d1ee4db3466cec75ce0b8b10431c81f62 /test/files/run
parentfbd5efe49cf23b446762dfa5026e8bac82ab04fc (diff)
downloadscala-1e0707786b118e3e33379e7acdc75306b45e6547.tar.gz
scala-1e0707786b118e3e33379e7acdc75306b45e6547.tar.bz2
scala-1e0707786b118e3e33379e7acdc75306b45e6547.zip
Hardens classToType logic
Reflection now correctly processes classes, objects and inner classes that are declared in classes and objects. However classToType still crashes on compound types and local classes. For more information on those, follow the links: * Compound types: https://issues.scala-lang.org/browse/SI-5430 * Local classes: https://issues.scala-lang.org/browse/SI-5431 Fixes https://issues.scala-lang.org/browse/SI-5256. Review by @paulp, @odersky.
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/t5256a.check2
-rw-r--r--test/files/run/t5256a.scala9
-rw-r--r--test/files/run/t5256b.check2
-rw-r--r--test/files/run/t5256b.scala8
-rw-r--r--test/files/run/t5256d.check20
-rw-r--r--test/files/run/t5256d.scala10
-rw-r--r--test/files/run/t5256e.check2
-rw-r--r--test/files/run/t5256e.scala9
-rw-r--r--test/files/run/t5256f.check4
-rw-r--r--test/files/run/t5256f.scala19
10 files changed, 85 insertions, 0 deletions
diff --git a/test/files/run/t5256a.check b/test/files/run/t5256a.check
new file mode 100644
index 0000000000..304f4ddd79
--- /dev/null
+++ b/test/files/run/t5256a.check
@@ -0,0 +1,2 @@
+A
+true
diff --git a/test/files/run/t5256a.scala b/test/files/run/t5256a.scala
new file mode 100644
index 0000000000..05a935c770
--- /dev/null
+++ b/test/files/run/t5256a.scala
@@ -0,0 +1,9 @@
+import scala.reflect.mirror._
+
+class A
+
+object Test extends App {
+ val c = classToType(classOf[A])
+ println(c)
+ println(c.typeSymbol == classToSymbol(classOf[A]))
+}
diff --git a/test/files/run/t5256b.check b/test/files/run/t5256b.check
new file mode 100644
index 0000000000..64f4c01166
--- /dev/null
+++ b/test/files/run/t5256b.check
@@ -0,0 +1,2 @@
+Test.A
+true \ No newline at end of file
diff --git a/test/files/run/t5256b.scala b/test/files/run/t5256b.scala
new file mode 100644
index 0000000000..5575211641
--- /dev/null
+++ b/test/files/run/t5256b.scala
@@ -0,0 +1,8 @@
+import scala.reflect.mirror._
+
+object Test extends App {
+ class A
+ val c = classToType(classOf[A])
+ println(c)
+ println(c.typeSymbol == classToSymbol(classOf[A]))
+}
diff --git a/test/files/run/t5256d.check b/test/files/run/t5256d.check
new file mode 100644
index 0000000000..7924c15c5c
--- /dev/null
+++ b/test/files/run/t5256d.check
@@ -0,0 +1,20 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import scala.reflect.mirror._
+import scala.reflect.mirror._
+
+scala> class A
+defined class A
+
+scala> val c = classToType(classOf[A])
+c: reflect.mirror.Type = A
+
+scala> println(c.typeSymbol == classToSymbol(classOf[A]))
+true
+
+scala>
+
+scala>
diff --git a/test/files/run/t5256d.scala b/test/files/run/t5256d.scala
new file mode 100644
index 0000000000..86404a9b63
--- /dev/null
+++ b/test/files/run/t5256d.scala
@@ -0,0 +1,10 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ def code = """
+import scala.reflect.mirror._
+class A
+val c = classToType(classOf[A])
+println(c.typeSymbol == classToSymbol(classOf[A]))
+ """
+}
diff --git a/test/files/run/t5256e.check b/test/files/run/t5256e.check
new file mode 100644
index 0000000000..e50f917e14
--- /dev/null
+++ b/test/files/run/t5256e.check
@@ -0,0 +1,2 @@
+C.this.A
+true \ No newline at end of file
diff --git a/test/files/run/t5256e.scala b/test/files/run/t5256e.scala
new file mode 100644
index 0000000000..9ed422ca44
--- /dev/null
+++ b/test/files/run/t5256e.scala
@@ -0,0 +1,9 @@
+import scala.reflect.mirror._
+
+class C { class A }
+
+object Test extends App {
+ val c = classToType(classOf[C#A])
+ println(c)
+ println(c.typeSymbol == classToSymbol(classOf[C#A]))
+}
diff --git a/test/files/run/t5256f.check b/test/files/run/t5256f.check
new file mode 100644
index 0000000000..ad2f375d9a
--- /dev/null
+++ b/test/files/run/t5256f.check
@@ -0,0 +1,4 @@
+Test.A1
+true
+Test.this.A2
+true
diff --git a/test/files/run/t5256f.scala b/test/files/run/t5256f.scala
new file mode 100644
index 0000000000..45c80cbd63
--- /dev/null
+++ b/test/files/run/t5256f.scala
@@ -0,0 +1,19 @@
+import scala.reflect.mirror._
+
+object Test extends App {
+ class A1
+
+ val c1 = classToType(classOf[A1])
+ println(c1)
+ println(c1.typeSymbol == classToSymbol(classOf[A1]))
+
+ new Test
+}
+
+class Test {
+ class A2
+
+ val c2 = classToType(classOf[A2])
+ println(c2)
+ println(c2.typeSymbol == classToSymbol(classOf[A2]))
+}