Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/dotty/DottyPredef.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package dotty

import scala.collection.mutable.WrappedArray
import scala.reflect.ClassTag
import scala.reflect.runtime.universe.TypeTag
import scala.runtime.ScalaRunTime.arrayElementClass
import scala.Predef.??? // this is currently ineffective, because of #530

abstract class I1 {
Expand Down Expand Up @@ -34,4 +36,15 @@ object DottyPredef extends I6 {

/** ClassTags for final classes */
implicit val NothingClassTag: ClassTag[Nothing] = ClassTag.Nothing

// This implicit will never be used for arrays of primitives because
// the wrap*Array in scala.Predef have a higher priority.
implicit def wrapVCArray[T <: AnyVal](xs: Array[T]): WrappedArray[T] =
new WrappedArray[T] {
val array = xs
lazy val elemTag = ClassTag[T](arrayElementClass(array.getClass))
def length: Int = array.length
def apply(index: Int): T = array(index)
def update(index: Int, elem: T) { array(index) = elem }
}
}
5 changes: 5 additions & 0 deletions src/dotty/runtime/Arrays.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ object Arrays {
arr
}

/** Method used only to remember the unerased type of an array of
* value class after erasure.
*/
def vcArray[T <: AnyVal](xs: Array[T], clazz: Class[_]): Array[T] = ???

/** Create an array of type T. T must be of form Array[E], with
* E being a reference type.
*/
Expand Down
Loading