@@ -23,8 +23,9 @@ import Symbols._
23
23
import Denotations ._
24
24
import Phases ._
25
25
import StdNames ._
26
+ import TypeErasure .ErasedValueType
26
27
27
- import dotty .tools .dotc .transform .Erasure
28
+ import dotty .tools .dotc .transform .{ Erasure , ValueClasses }
28
29
import dotty .tools .dotc .util .SourcePosition
29
30
import dotty .tools .dotc .util .Spans .Span
30
31
import dotty .tools .dotc .report
@@ -2599,10 +2600,10 @@ class JSCodeGen()(using genCtx: Context) {
2599
2600
case tpe if isPrimitiveValueType(tpe) =>
2600
2601
makePrimitiveBox(expr, tpe)
2601
2602
2602
- /* case tpe: ErasedValueType =>
2603
- val boxedClass = tpe.valueClazz
2603
+ case tpe : ErasedValueType =>
2604
+ val boxedClass = tpe.tycon.typeSymbol
2604
2605
val ctor = boxedClass.primaryConstructor
2605
- genNew( boxedClass, ctor, List(expr))*/
2606
+ js. New (encodeClassName( boxedClass), encodeMethodSym( ctor) , List (expr))
2606
2607
2607
2608
case _ =>
2608
2609
expr
@@ -2626,15 +2627,15 @@ class JSCodeGen()(using genCtx: Context) {
2626
2627
case tpe if isPrimitiveValueType(tpe) =>
2627
2628
makePrimitiveUnbox(expr, tpe)
2628
2629
2629
- /* case tpe: ErasedValueType =>
2630
- val boxedClass = tpe.valueClazz
2631
- val unboxMethod = boxedClass.derivedValueClassUnbox
2630
+ case tpe : ErasedValueType =>
2631
+ val boxedClass = tpe.tycon.typeSymbol.asClass
2632
+ val unboxMethod = ValueClasses .valueClassUnbox(boxedClass)
2632
2633
val content = genApplyMethod(
2633
- genAsInstanceOf (expr, tpe ), unboxMethod, Nil)
2634
- if (unboxMethod.tpe .resultType <:< tpe.erasedUnderlying)
2634
+ js. AsInstanceOf (expr, encodeClassType(boxedClass) ), unboxMethod, Nil )
2635
+ if (unboxMethod.info .resultType <:< tpe.erasedUnderlying)
2635
2636
content
2636
2637
else
2637
- fromAny (content, tpe.erasedUnderlying)*/
2638
+ unbox (content, tpe.erasedUnderlying)
2638
2639
2639
2640
case tpe =>
2640
2641
genAsInstanceOf(expr, tpe)
@@ -3587,8 +3588,9 @@ class JSCodeGen()(using genCtx: Context) {
3587
3588
3588
3589
private def isPrimitiveValueType (tpe : Type ): Boolean = {
3589
3590
tpe.widenDealias match {
3590
- case JavaArrayType (_) => false
3591
- case t => t.typeSymbol.asClass.isPrimitiveValueClass
3591
+ case JavaArrayType (_) => false
3592
+ case _ : ErasedValueType => false
3593
+ case t => t.typeSymbol.asClass.isPrimitiveValueClass
3592
3594
}
3593
3595
}
3594
3596
0 commit comments