diff options
author | Paul Phillips <paulp@improving.org> | 2013-05-24 05:43:58 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-05-27 13:04:45 -0700 |
commit | e26f5c412a2498c23c8cc3e975208a71f8f7d558 (patch) | |
tree | 41d35674cd70aa47ec0a9faf707d2994f6c1b580 | |
parent | e42991f40707023d563f43bf66f3d8b9a637aa1b (diff) | |
download | scala-e26f5c412a2498c23c8cc3e975208a71f8f7d558.tar.gz scala-e26f5c412a2498c23c8cc3e975208a71f8f7d558.tar.bz2 scala-e26f5c412a2498c23c8cc3e975208a71f8f7d558.zip |
SI-7088 Array crasher in erasure.
The usual business where half our pattern matches are missing
half the necessary cases.
-rw-r--r-- | src/reflect/scala/reflect/internal/transform/Erasure.scala | 6 | ||||
-rw-r--r-- | test/files/run/t7088.check | 2 | ||||
-rw-r--r-- | test/files/run/t7088.scala | 13 |
3 files changed, 20 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala index a9a1285de3..580ada8254 100644 --- a/src/reflect/scala/reflect/internal/transform/Erasure.scala +++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala @@ -55,9 +55,13 @@ trait Erasure { } } + /** Arrays despite their finality may turn up as refined type parents, + * e.g. with "tagged types" like Array[Int] with T. + */ protected def unboundedGenericArrayLevel(tp: Type): Int = tp match { case GenericArray(level, core) if !(core <:< AnyRefTpe) => level - case _ => 0 + case RefinedType(ps, _) if ps.nonEmpty => logResult(s"Unbounded generic level for $tp is")(ps map unboundedGenericArrayLevel max) + case _ => 0 } // @M #2585 when generating a java generic signature that includes diff --git a/test/files/run/t7088.check b/test/files/run/t7088.check new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/test/files/run/t7088.check @@ -0,0 +1,2 @@ +1 +2 diff --git a/test/files/run/t7088.scala b/test/files/run/t7088.scala new file mode 100644 index 0000000000..5f0114b940 --- /dev/null +++ b/test/files/run/t7088.scala @@ -0,0 +1,13 @@ +object Test { + type Tag[X] = {type Tag = X} + type TaggedArray[T] = Array[T] with Tag[Any] + + def method[T: scala.reflect.ClassTag](a: TaggedArray[T], value: T) { + a.update(0, value) + a foreach println + } + + def main(args: Array[String]): Unit = { + method(Array(1, 2).asInstanceOf[TaggedArray[Int]], 1) + } +} |