Skip to content
Browse files

Fix for SI-5654.

More details as code comment and in the bug database.
  • Loading branch information
lrytz committed May 10, 2012
1 parent aa555de commit 23afe3c9b9ff6f1c9d31cea678909003ca8f943b
Showing with 21 additions and 1 deletion.
  1. +8 −1 src/compiler/scala/reflect/internal/transform/Erasure.scala
  2. +13 −0 test/files/pos/t5654.scala
@@ -17,7 +17,14 @@ trait Erasure {
* with primitive as well as class types)?.
private def genericCore(tp: Type): Type = tp.normalize match {
case TypeRef(_, sym, _) if sym.isAbstractType && !sym.owner.isJavaDefined =>
/* A Java Array<T> is erased to Array[Object] (T can only be a reference type), where as a Scala Array[T] is
* erased to Object. However, there is only symbol for the Array class. So to make the distinction between
* a Java and a Scala array, we check if the owner of T comes from a Java class.
* This however caused issue SI-5654. The additional test for EXSITENTIAL fixes it, see the ticket comments.
* In short, members of an existential type (e.g. `T` in `forSome { type T }`) can have pretty arbitrary
* owners (e.g. when computing lubs, <root> is used). All packageClass symbols have `isJavaDefined == true`.
case TypeRef(_, sym, _) if sym.isAbstractType && (!sym.owner.isJavaDefined || sym.hasFlag(Flags.EXISTENTIAL)) =>
case ExistentialType(tparams, restp) =>
@@ -0,0 +1,13 @@
class T(val a: Array[_])

class U {
val a = Array(Array(1, 2), Array("a","b"))

class T1 { val a: Array[_] = Array(1) }

case class Bomb(a: Array[_])
case class Bomb2(a: Array[T] forSome { type T })
class Okay1(a: Array[_])
case class Okay2(s: Seq[_])

0 comments on commit 23afe3c

Please sign in to comment.
You can’t perform that action at this time.