summaryrefslogtreecommitdiff
path: root/test/files/run/t8931.scala
diff options
context:
space:
mode:
authorAntoine Gourlay <antoine@gourlay.fr>2014-10-27 16:11:23 +0100
committerAntoine Gourlay <antoine@gourlay.fr>2014-11-05 11:54:07 +0100
commitced3ca8ae1aedd37591d85474d9ee85be5c9b56a (patch)
treeba5993b69c2314dda9c7416f3bf0c63727de9f3d /test/files/run/t8931.scala
parentbdae51d6a8f18a5456a32c350cb551d42a3cb6c6 (diff)
downloadscala-ced3ca8ae1aedd37591d85474d9ee85be5c9b56a.tar.gz
scala-ced3ca8ae1aedd37591d85474d9ee85be5c9b56a.tar.bz2
scala-ced3ca8ae1aedd37591d85474d9ee85be5c9b56a.zip
SI-8931 make generic signature consistent with interface list in classfiles
An optimization was introduced in 7a99c03 (SI-5278) to remove redundant interfaces from the list of implemented interfaces in the bytecode. However the same change was not propagated to the generic signature of a class, which also contains a list of direct parent classes and interfaces. The JVM does not check the well-formedness of signatures at class loading or linking (see ยง4.3.4 of jdk7 jvms), but other tools might assume the number of implemented interfaces is the same whether one asked for generic or erased interfaces. It doesn't break reflection so nobody complained, but it does show: scala> val c = classOf[Tuple1[String]] c: Class[(String,)] = class scala.Tuple1 scala> c.getInterfaces // Product is gone res0: Array[Class[_]] = Array(interface scala.Product1, interface scala.Serializable) scala> c.getGenericInterfaces // Product is back! res1: Array[java.lang.reflect.Type] = Array(scala.Product1<T1>, interface scala.Product, interface scala.Serializable) This moves the optimization to erasure, for use in emitting the generic signature, and the backend calls into it later for the list of interfaces.
Diffstat (limited to 'test/files/run/t8931.scala')
-rw-r--r--test/files/run/t8931.scala15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/files/run/t8931.scala b/test/files/run/t8931.scala
new file mode 100644
index 0000000000..11718471bc
--- /dev/null
+++ b/test/files/run/t8931.scala
@@ -0,0 +1,15 @@
+
+trait A
+
+trait B extends A
+
+class C extends A with B
+
+object Test extends App {
+ val c = classOf[C]
+
+ println(c.getGenericInterfaces.toList)
+
+ assert(c.getGenericInterfaces.length == c.getInterfaces.length,
+ s"mismatch between ${c.getGenericInterfaces} and ${c.getInterfaces}")
+}