Skip to content

Commit e37edd2

Browse files
committed
arrayTag impl for vcArrays is moved to VCXCompanions
1 parent 7832e35 commit e37edd2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/dotty/DottyPredef.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@ object DottyPredef {
1313
implicit def typeTag[T]: TypeTag[T] = ???
1414

1515
implicit def arrayTag[T](implicit ctag: ClassTag[T]): ClassTag[Array[T]] =
16-
ctag match {
17-
case _: VCIntCompanion[_] | _: VCShortCompanion[_] |
18-
_: VCLongCompanion[_] | _: VCFloatCompanion[_] |
19-
_: VCDoubleCompanion[_] | _: VCBooleanCompanion[_] |
20-
_: VCByteCompanion[_] | _: VCObjectCompanion[_] |
21-
_: VCCharCompanion[_] => ClassTag[Array[T]](ctag.newArray(0).getClass)
22-
case _ => ctag.wrap
23-
}
16+
ctag.wrap
2417

2518
def wrapVCArray[T](xs: Array[T]): WrappedArray[T] = {
2619
new WrappedArray[T] {

src/dotty/runtime/vc/VCPrototype.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ abstract class VCFloatCompanion[T /*<: VCFloatPrototype*/] extends ClassTag[T] {
5353
implicit def classTag: this.type = this
5454
override def newArray(len: Int): Array[T] =
5555
new VCFloatArray(this.asInstanceOf[VCFloatCompanion[VCFloatPrototype]], len).asInstanceOf[Array[T]]
56+
override def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](this.newArray(0).getClass)
5657

5758

5859
def _1$extension(underlying: Float) = underlying
@@ -108,6 +109,7 @@ abstract class VCObjectCompanion[T /*<: VCObjectPrototype*/] extends ClassTag[T]
108109
implicit def classTag: this.type = this
109110
override def newArray(len: Int): Array[T] =
110111
new VCObjectArray(this.asInstanceOf[VCObjectCompanion[VCObjectPrototype]], len).asInstanceOf[Array[T]]
112+
override def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](this.newArray(0).getClass)
111113

112114

113115
def _1$extension(underlying: Object) = underlying
@@ -165,6 +167,7 @@ abstract class VCShortCompanion[T /*<: VCShortPrototype*/] extends ClassTag[T] {
165167
implicit def classTag: this.type = this
166168
override def newArray(len: Int): Array[T] =
167169
new VCShortArray(this.asInstanceOf[VCShortCompanion[VCShortPrototype]], len).asInstanceOf[Array[T]]
170+
override def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](this.newArray(0).getClass)
168171

169172

170173
def _1$extension(underlying: Short) = underlying
@@ -223,6 +226,7 @@ abstract class VCLongCompanion[T /*<: VCLongPrototype*/] extends ClassTag[T] {
223226
implicit def classTag: this.type = this
224227
override def newArray(len: Int): Array[T] =
225228
new VCLongArray(this.asInstanceOf[VCLongCompanion[VCLongPrototype]], len).asInstanceOf[Array[T]]
229+
override def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](this.newArray(0).getClass)
226230

227231

228232
def _1$extension(underlying: Long) = underlying
@@ -279,6 +283,7 @@ abstract class VCIntCompanion[T /*<: VCIntPrototype*/] extends ClassTag[T] {
279283
implicit def classTag: this.type = this
280284
override def newArray(len: Int): Array[T] =
281285
new VCIntArray(this.asInstanceOf[VCIntCompanion[VCIntPrototype]], len).asInstanceOf[Array[T]]
286+
override def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](this.newArray(0).getClass)
282287

283288
def _1$extension(underlying: Int) = underlying
284289
def hashCode$extension(underlying: Int) = underlying.hashCode()
@@ -333,6 +338,7 @@ abstract class VCDoubleCompanion[T /*<: VCDoublePrototype*/] extends ClassTag[T]
333338
implicit def classTag: this.type = this
334339
override def newArray(len: Int): Array[T] =
335340
new VCDoubleArray(this.asInstanceOf[VCDoubleCompanion[VCDoublePrototype]], len).asInstanceOf[Array[T]]
341+
override def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](this.newArray(0).getClass)
336342

337343

338344
def _1$extension(underlying: Double) = underlying
@@ -388,6 +394,7 @@ abstract class VCBooleanCompanion[T /*<: VCBooleanPrototype*/] extends ClassTag[
388394
implicit def classTag: this.type = this
389395
override def newArray(len: Int): Array[T] =
390396
new VCBooleanArray(this.asInstanceOf[VCBooleanCompanion[VCBooleanPrototype]], len).asInstanceOf[Array[T]]
397+
override def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](this.newArray(0).getClass)
391398

392399

393400
def _1$extension(underlying: Boolean) = underlying
@@ -447,6 +454,7 @@ abstract class VCCharCompanion[T /*<: VCCharPrototype*/] extends ClassTag[T] {
447454
implicit def classTag: this.type = this
448455
override def newArray(len: Int): Array[T] =
449456
new VCCharArray(this.asInstanceOf[VCCharCompanion[VCCharPrototype]], len).asInstanceOf[Array[T]]
457+
override def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](this.newArray(0).getClass)
450458

451459

452460
def _1$extension(underlying: Char) = underlying
@@ -502,6 +510,7 @@ abstract class VCByteCompanion[T /*<: VCBytePrototype*/] extends ClassTag[T] {
502510
implicit def classTag: this.type = this
503511
override def newArray(len: Int): Array[T] =
504512
new VCByteArray(this.asInstanceOf[VCByteCompanion[VCBytePrototype]], len).asInstanceOf[Array[T]]
513+
override def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](this.newArray(0).getClass)
505514

506515

507516
def _1$extension(underlying: Byte) = underlying

0 commit comments

Comments
 (0)