summaryrefslogtreecommitdiff
path: root/test/files/run/reflection-equality.check
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-07-03 22:39:38 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-07-04 20:47:22 +0400
commit0529dd502a45e29aa617986ff9ab29e145d62582 (patch)
tree992e898503ee18b2eff4e59c3a345889bac852bf /test/files/run/reflection-equality.check
parent1fe5087c8e7713cbb42e1da6c1486de3531dd544 (diff)
downloadscala-0529dd502a45e29aa617986ff9ab29e145d62582.tar.gz
scala-0529dd502a45e29aa617986ff9ab29e145d62582.tar.bz2
scala-0529dd502a45e29aa617986ff9ab29e145d62582.zip
SI-5959 type equality now accounts for mirrors
TypeRef(ThisType(<package1>), sym, args) should always be equal to TypeRef(ThisType(<package2>), sym, args) regardless of whether package1 and package2 actually represent the same symbols of not. This goes for subtyping (<:<) and type equality (=:=). However regular equality (==) and hashconsing is unaffected as per http://groups.google.com/group/scala-internals/browse_thread/thread/4bef4e6987bb68fe This is done to account for the fact that mirrors share normal symbols, but never share package symbols. Therefore at times it will occur that the same types loaded by different mirrors appear different because of the package symbols. More details: https://issues.scala-lang.org/browse/SI-5959.
Diffstat (limited to 'test/files/run/reflection-equality.check')
-rw-r--r--test/files/run/reflection-equality.check53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/files/run/reflection-equality.check b/test/files/run/reflection-equality.check
new file mode 100644
index 0000000000..feafb58d3b
--- /dev/null
+++ b/test/files/run/reflection-equality.check
@@ -0,0 +1,53 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> class X {
+ def methodIntIntInt(x: Int, y: Int) = x+y
+}
+defined class X
+
+scala>
+
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
+
+scala> import scala.reflect.runtime.{ currentMirror => cm }
+import scala.reflect.runtime.{currentMirror=>cm}
+
+scala> def im: InstanceMirror = cm.reflect(new X)
+im: reflect.runtime.universe.InstanceMirror
+
+scala> val cs: ClassSymbol = im.symbol
+cs: reflect.runtime.universe.ClassSymbol = class X
+
+scala> val ts: Type = cs.typeSignature
+ts: reflect.runtime.universe.Type =
+java.lang.Object {
+ def <init>: <?>
+ def methodIntIntInt: <?>
+}
+
+scala> val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethodSymbol
+ms: reflect.runtime.universe.MethodSymbol = method methodIntIntInt
+
+scala> val MethodType( _, t1 ) = ms.typeSignature
+t1: reflect.runtime.universe.Type = scala.Int
+
+scala> val t2 = typeOf[scala.Int]
+t2: reflect.runtime.universe.Type = Int
+
+scala> t1 == t2
+res0: Boolean = false
+
+scala> t1 =:= t2
+res1: Boolean = true
+
+scala> t1 <:< t2
+res2: Boolean = true
+
+scala> t2 <:< t1
+res3: Boolean = true
+
+scala>