Skip to content

Commit 44f6142

Browse files
committed
Make IArray covariant
1 parent f1645d4 commit 44f6142

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

library/src-bootstrapped/scala/IArray.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import reflect.ClassTag
77
* But this means `IArray[Int]`, which erases to `Int[]`, cannot be a subtype of
88
* `IArray[Any]`.
99
*/
10-
opaque type IArray[T] = Array[T]
10+
opaque type IArray[+T] = Array[_ <: T]
1111

1212
object IArray {
1313

1414
implied arrayOps {
15-
inline def (arr: IArray[T]) apply[T] (n: Int): T = (arr: Array[T]).apply(n)
16-
inline def (arr: IArray[T]) length[T] : Int = (arr: Array[T]).length
15+
inline def (arr: IArray[T]) apply[T] (n: Int): T = arr.asInstanceOf[Array[T]].apply(n)
16+
inline def (arr: IArray[T]) length[T] : Int = arr.asInstanceOf[Array[T]].length
1717
}
1818
def apply[T: ClassTag](xs: T*): IArray[T] = Array(xs: _*)
1919

@@ -27,7 +27,7 @@ object IArray {
2727
def apply(x: Double, xs: Double*): IArray[Double] = Array(x, xs: _*)
2828
def apply(x: Unit, xs: Unit*): IArray[Unit] = Array(x, xs: _*)
2929

30-
def concat[T: ClassTag](xss: IArray[T]*): IArray[T] = Array.concat(xss: _*)
30+
def concat[T: ClassTag](xss: IArray[T]*): IArray[T] = Array.concat[T](xss.asInstanceOf[Seq[Array[T]]]: _*)
3131

3232
def fill[T: ClassTag](n: Int)(elem: => T): IArray[T] =
3333
Array.fill(n)(elem)
@@ -56,5 +56,5 @@ object IArray {
5656

5757
def iterate[T: ClassTag](start: T, len: Int)(f: T => T): IArray[T] = Array.iterate(start, len)(f)
5858

59-
def unapplySeq[T](x: IArray[T]): Option[IndexedSeq[T]] = Array.unapplySeq(x)
59+
def unapplySeq[T](x: IArray[T]): Option[IndexedSeq[T]] = Array.unapplySeq[T](x.asInstanceOf[Array[T]])
6060
}

0 commit comments

Comments
 (0)