@@ -29,13 +29,20 @@ abstract class VCFloatCasePrototype(underlying: Float) extends VCFloatPrototype(
29
29
}
30
30
}
31
31
32
- abstract class VCFloatCompanion [T <: VCFloatPrototype ] extends ClassTag [T ] {
32
+ // NOTE for all VCXCompanion: The type parameter T should be bounded like this:
33
+ // abstract class VCXCompanion[T <: VCXPrototype] extends ClassTag[T]
34
+ // But this affects erasure: it means that Array[T] is erased to [VCIntPrototype;
35
+ // instead of Object, but we really need it to erase to Object if we want
36
+ // VCXArray to be a valid array. We work around this by adding casts where
37
+ // we need to assume that T is a subtype of VCXPrototype.
38
+
39
+ abstract class VCFloatCompanion [T /* <: VCFloatPrototype*/ ] extends ClassTag [T ] {
33
40
def box (underlying : Float ): T
34
- final def unbox (boxed : T ) = boxed.underlying
41
+ final def unbox (boxed : T ) = boxed.asInstanceOf [ VCFloatPrototype ]. underlying
35
42
36
43
implicit def classTag : this .type = this
37
44
override def newArray (len : Int ): Array [T ] =
38
- new VCFloatArray (this , len).asInstanceOf [Array [T ]]
45
+ new VCFloatArray (this . asInstanceOf [ VCFloatCompanion [ VCFloatPrototype ]] , len).asInstanceOf [Array [T ]]
39
46
40
47
41
48
final def _1$extension (underlying : Float ) = underlying
@@ -80,13 +87,13 @@ abstract class VCObjectCasePrototype(underlying: Object) extends VCObjectPrototy
80
87
}
81
88
}
82
89
83
- abstract class VCObjectCompanion [T <: VCObjectPrototype ] extends ClassTag [T ] {
90
+ abstract class VCObjectCompanion [T /* <: VCObjectPrototype*/ ] extends ClassTag [T ] {
84
91
def box (underlying : Object ): T
85
- final def unbox (boxed : T ) = boxed.underlying
92
+ final def unbox (boxed : T ) = boxed.asInstanceOf [ VCObjectPrototype ]. underlying
86
93
87
94
implicit def classTag : this .type = this
88
95
override def newArray (len : Int ): Array [T ] =
89
- new VCObjectArray (this , len).asInstanceOf [Array [T ]]
96
+ new VCObjectArray (this . asInstanceOf [ VCObjectCompanion [ VCObjectPrototype ]] , len).asInstanceOf [Array [T ]]
90
97
91
98
92
99
final def _1$extension (underlying : Object ) = underlying
@@ -133,13 +140,13 @@ abstract class VCShortCasePrototype(underlying: Short) extends VCShortPrototype(
133
140
}
134
141
}
135
142
136
- abstract class VCShortCompanion [T <: VCShortPrototype ] extends ClassTag [T ] {
143
+ abstract class VCShortCompanion [T /* <: VCShortPrototype*/ ] extends ClassTag [T ] {
137
144
def box (underlying : Short ): T
138
- final def unbox (boxed : T ) = boxed.underlying
145
+ final def unbox (boxed : T ) = boxed.asInstanceOf [ VCShortPrototype ]. underlying
139
146
140
147
implicit def classTag : this .type = this
141
148
override def newArray (len : Int ): Array [T ] =
142
- new VCShortArray (this , len).asInstanceOf [Array [T ]]
149
+ new VCShortArray (this . asInstanceOf [ VCShortCompanion [ VCShortPrototype ]] , len).asInstanceOf [Array [T ]]
143
150
144
151
145
152
final def _1$extension (underlying : Short ) = underlying
@@ -187,13 +194,13 @@ abstract class VCLongCasePrototype(underlying: Long) extends VCLongPrototype(und
187
194
}
188
195
}
189
196
190
- abstract class VCLongCompanion [T <: VCLongPrototype ] extends ClassTag [T ] {
197
+ abstract class VCLongCompanion [T /* <: VCLongPrototype*/ ] extends ClassTag [T ] {
191
198
def box (underlying : Long ): T
192
- final def unbox (boxed : T ) = boxed.underlying
199
+ final def unbox (boxed : T ) = boxed.asInstanceOf [ VCLongPrototype ]. underlying
193
200
194
201
implicit def classTag : this .type = this
195
202
override def newArray (len : Int ): Array [T ] =
196
- new VCLongArray (this , len).asInstanceOf [Array [T ]]
203
+ new VCLongArray (this . asInstanceOf [ VCLongCompanion [ VCLongPrototype ]] , len).asInstanceOf [Array [T ]]
197
204
198
205
199
206
final def _1$extension (underlying : Long ) = underlying
@@ -240,13 +247,13 @@ abstract class VCIntCasePrototype(underlying: Int) extends VCIntPrototype(underl
240
247
}
241
248
}
242
249
243
- abstract class VCIntCompanion [T <: VCIntPrototype ] extends ClassTag [T ] {
250
+ abstract class VCIntCompanion [T /* <: VCIntPrototype*/ ] extends ClassTag [T ] {
244
251
def box (underlying : Int ): T
245
- final def unbox (boxed : T ) = boxed.underlying
252
+ final def unbox (boxed : T ) = boxed.asInstanceOf [ VCIntPrototype ]. underlying
246
253
247
254
implicit def classTag : this .type = this
248
255
override def newArray (len : Int ): Array [T ] =
249
- new VCIntArray (this , len).asInstanceOf [Array [T ]]
256
+ new VCIntArray (this . asInstanceOf [ VCIntCompanion [ VCIntPrototype ]] , len).asInstanceOf [Array [T ]]
250
257
251
258
252
259
final def _1$extension (underlying : Int ) = underlying
@@ -291,13 +298,13 @@ abstract class VCDoubleCasePrototype(underlying: Double) extends VCDoublePrototy
291
298
}
292
299
}
293
300
294
- abstract class VCDoubleCompanion [T <: VCDoublePrototype ] extends ClassTag [T ] {
301
+ abstract class VCDoubleCompanion [T /* <: VCDoublePrototype*/ ] extends ClassTag [T ] {
295
302
def box (underlying : Double ): T
296
- final def unbox (boxed : T ) = boxed.underlying
303
+ final def unbox (boxed : T ) = boxed.asInstanceOf [ VCDoublePrototype ]. underlying
297
304
298
305
implicit def classTag : this .type = this
299
306
override def newArray (len : Int ): Array [T ] =
300
- new VCDoubleArray (this , len).asInstanceOf [Array [T ]]
307
+ new VCDoubleArray (this . asInstanceOf [ VCDoubleCompanion [ VCDoublePrototype ]] , len).asInstanceOf [Array [T ]]
301
308
302
309
303
310
final def _1$extension (underlying : Double ) = underlying
@@ -342,13 +349,13 @@ abstract class VCBooleanCasePrototype(underlying: Boolean) extends VCBooleanProt
342
349
}
343
350
}
344
351
345
- abstract class VCBooleanCompanion [T <: VCBooleanPrototype ] extends ClassTag [T ] {
352
+ abstract class VCBooleanCompanion [T /* <: VCBooleanPrototype*/ ] extends ClassTag [T ] {
346
353
def box (underlying : Boolean ): T
347
- final def unbox (boxed : T ) = boxed.underlying
354
+ final def unbox (boxed : T ) = boxed.asInstanceOf [ VCBooleanPrototype ]. underlying
348
355
349
356
implicit def classTag : this .type = this
350
357
override def newArray (len : Int ): Array [T ] =
351
- new VCBooleanArray (this , len).asInstanceOf [Array [T ]]
358
+ new VCBooleanArray (this . asInstanceOf [ VCBooleanCompanion [ VCBooleanPrototype ]] , len).asInstanceOf [Array [T ]]
352
359
353
360
354
361
final def _1$extension (underlying : Boolean ) = underlying
@@ -397,13 +404,13 @@ abstract class VCCharCasePrototype(underlying: Char) extends VCCharPrototype(und
397
404
// subclasses are expected to implement equals, productPrefix, and canEqual
398
405
}
399
406
400
- abstract class VCCharCompanion [T <: VCCharPrototype ] extends ClassTag [T ] {
407
+ abstract class VCCharCompanion [T /* <: VCCharPrototype*/ ] extends ClassTag [T ] {
401
408
def box (underlying : Char ): T
402
- final def unbox (boxed : T ) = boxed.underlying
409
+ final def unbox (boxed : T ) = boxed.asInstanceOf [ VCCharPrototype ]. underlying
403
410
404
411
implicit def classTag : this .type = this
405
412
override def newArray (len : Int ): Array [T ] =
406
- new VCCharArray (this , len).asInstanceOf [Array [T ]]
413
+ new VCCharArray (this . asInstanceOf [ VCCharCompanion [ VCCharPrototype ]] , len).asInstanceOf [Array [T ]]
407
414
408
415
409
416
final def _1$extension (underlying : Char ) = underlying
@@ -448,13 +455,13 @@ abstract class VCByteCasePrototype(underlying: Byte) extends VCBytePrototype(und
448
455
}
449
456
}
450
457
451
- abstract class VCByteCompanion [T <: VCBytePrototype ] extends ClassTag [T ] {
458
+ abstract class VCByteCompanion [T /* <: VCBytePrototype*/ ] extends ClassTag [T ] {
452
459
def box (underlying : Byte ): T
453
- final def unbox (boxed : T ) = boxed.underlying
460
+ final def unbox (boxed : T ) = boxed.asInstanceOf [ VCBytePrototype ]. underlying
454
461
455
462
implicit def classTag : this .type = this
456
463
override def newArray (len : Int ): Array [T ] =
457
- new VCByteArray (this , len).asInstanceOf [Array [T ]]
464
+ new VCByteArray (this . asInstanceOf [ VCByteCompanion [ VCBytePrototype ]] , len).asInstanceOf [Array [T ]]
458
465
459
466
460
467
final def _1$extension (underlying : Byte ) = underlying
0 commit comments