diff --git a/src/dotty/tools/dotc/core/TypeErasure.scala b/src/dotty/tools/dotc/core/TypeErasure.scala index 108d862a9914..e4f91914bbc2 100644 --- a/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/src/dotty/tools/dotc/core/TypeErasure.scala @@ -39,7 +39,7 @@ object TypeErasure { case _: ErasedValueType => true case tp: TypeRef => - tp.symbol.isClass && tp.symbol != defn.AnyClass + tp.symbol.isClass && tp.symbol != defn.AnyClass && tp.symbol != defn.ArrayClass case _: TermRef => true case JavaArrayType(elem) => @@ -321,6 +321,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean val sym = tp.symbol if (!sym.isClass) this(tp.info) else if (semiEraseVCs && isDerivedValueClass(sym)) eraseDerivedValueClassRef(tp) + else if (sym == defn.ArrayClass) apply(tp.appliedTo(TypeBounds.empty)) // i966 shows that we can hit a raw Array type. else eraseNormalClassRef(tp) case tp: RefinedType => val parent = tp.parent diff --git a/src/dotty/tools/dotc/transform/Erasure.scala b/src/dotty/tools/dotc/transform/Erasure.scala index 1b9b898f2140..3445b4c444ec 100644 --- a/src/dotty/tools/dotc/transform/Erasure.scala +++ b/src/dotty/tools/dotc/transform/Erasure.scala @@ -109,7 +109,11 @@ class Erasure extends Phase with DenotTransformer { thisTransformer => } def assertErased(tp: Type, tree: tpd.Tree = tpd.EmptyTree)(implicit ctx: Context): Unit = - assert(isErasedType(tp), i"The type $tp - ${tp.toString} of class ${tp.getClass} of tree $tree : ${tree.tpe} / ${tree.getClass} is illegal after erasure, phase = ${ctx.phase}") + if (tp.typeSymbol == defn.ArrayClass && + ctx.compilationUnit.source.file.name == "Array.scala") {} // ok + else + assert(isErasedType(tp), + i"The type $tp - ${tp.toString} of class ${tp.getClass} of tree $tree : ${tree.tpe} / ${tree.getClass} is illegal after erasure, phase = ${ctx.phase.prev}") } object Erasure extends TypeTestsCasts{ diff --git a/test/dotc/scala-collections.whitelist b/test/dotc/scala-collections.whitelist index 328d040c15bf..2abb16c1ec20 100644 --- a/test/dotc/scala-collections.whitelist +++ b/test/dotc/scala-collections.whitelist @@ -184,9 +184,7 @@ ./scala-scala/src/library/scala/collection/SeqViewLike.scala ./scala-scala/src/library/scala/collection/mutable/IndexedSeqView.scala ./scala-scala/src/library/scala/collection/immutable/StreamViewLike.scala - -## This class causes a crash in backend -> @darkdimius -#./scala-scala/src/library/scala/collection/immutable/TrieIterator.scala +./scala-scala/src/library/scala/collection/immutable/TrieIterator.scala ./scala-scala/src/library/scala/collection/immutable/HashMap.scala ./scala-scala/src/library/scala/collection/immutable/HashSet.scala diff --git a/tests/pos/i966.scala b/tests/pos/i966.scala new file mode 100644 index 000000000000..1fedc00238ff --- /dev/null +++ b/tests/pos/i966.scala @@ -0,0 +1,15 @@ +package scala +package collection +package immutable + +import HashMap.{ HashTrieMap, HashMapCollision1, HashMap1 } +import HashSet.{ HashTrieSet, HashSetCollision1, HashSet1 } + +object i996{ + + private[this] def collisionToArray[T](x: Iterable[T]): Array[Iterable[T]] = (x match { + case x: HashMapCollision1[_, _] => x.kvs.map(x => HashMap(x)).toArray + case x: HashSetCollision1[_] => x.ks.map(x => HashSet(x)).toArray + }).asInstanceOf[Array[Iterable[T]]] + +} diff --git a/tests/pos/i996.scala b/tests/pos/i996.scala new file mode 100644 index 000000000000..1fedc00238ff --- /dev/null +++ b/tests/pos/i996.scala @@ -0,0 +1,15 @@ +package scala +package collection +package immutable + +import HashMap.{ HashTrieMap, HashMapCollision1, HashMap1 } +import HashSet.{ HashTrieSet, HashSetCollision1, HashSet1 } + +object i996{ + + private[this] def collisionToArray[T](x: Iterable[T]): Array[Iterable[T]] = (x match { + case x: HashMapCollision1[_, _] => x.kvs.map(x => HashMap(x)).toArray + case x: HashSetCollision1[_] => x.ks.map(x => HashSet(x)).toArray + }).asInstanceOf[Array[Iterable[T]]] + +}