@@ -775,39 +775,49 @@ class Definitions {
775
775
/** The type of the boxed class corresponding to primitive value type `tp`. */
776
776
def boxedType (tp : Type )(implicit ctx : Context ): TypeRef = boxedTypes(scalaClassName(tp))
777
777
778
- lazy val vcPrototypeClassKeys : collection.Set [Symbol ] =
779
- defn.ScalaNumericValueClasses () + defn.BooleanClass + defn.ObjectClass
778
+ lazy val vcPrototypeTypeKeys : collection.Set [TypeRef ] =
779
+ defn.ScalaNumericValueTypes + defn.BooleanType + defn.ObjectType
780
780
781
- lazy val vcPrototype : Map [Symbol , Symbol ] =
782
- vcPrototypeClassKeys .map(vc => vc -> ctx.requiredClass (s " dotty.runtime.vc.VC ${vc.name}Prototype " )).toMap
783
- lazy val vcCompanion : Map [Symbol , Symbol ] =
784
- vcPrototypeClassKeys .map(vc => vc -> ctx.requiredClass (s " dotty.runtime.vc.VC ${vc.name}Companion " )).toMap
785
- lazy val vcArray : Map [Symbol , Symbol ] =
786
- vcPrototypeClassKeys .map(vc => vc -> ctx.requiredClass (s " dotty.runtime.vc.VC ${vc.name}Array " )).toMap
781
+ lazy val vcPrototypeTypes : Map [TypeName , TypeRef ] =
782
+ vcPrototypeTypeKeys .map(vc => vc.name -> ctx.requiredClassRef (s " dotty.runtime.vc.VC ${vc.name}Prototype " )).toMap
783
+ lazy val vcCompanionTypes : Map [TypeName , TypeRef ] =
784
+ vcPrototypeTypeKeys .map(vc => vc.name -> ctx.requiredClassRef (s " dotty.runtime.vc.VC ${vc.name}Companion " )).toMap
785
+ lazy val vcArrayTypes : Map [TypeName , TypeRef ] =
786
+ vcPrototypeTypeKeys .map(vc => vc.name -> ctx.requiredClassRef (s " dotty.runtime.vc.VC ${vc.name}Array " )).toMap
787
787
788
- lazy val VCArrayPrototypeClass = ctx.requiredClass(s " dotty.runtime.vc.VCArrayPrototype " )
788
+ // TODO: rewrite
789
+ def vcPrototypeValues (implicit ctx : Context ): Set [Symbol ] = vcPrototypeTypes.values.toSet map {tr : TypeRef => tr.classSymbol}
789
790
790
- lazy val vcPrototypeValues = vcPrototype.values.toSet
791
-
792
- def VCArrayPrototypeType = VCArrayPrototypeClass .typeRef
791
+ lazy val VCArrayPrototypeType = ctx.requiredClassRef(s " dotty.runtime.vc.VCArrayPrototype " )
792
+ def VCArrayPrototypeClass (implicit ctx : Context ) = VCArrayPrototypeType .classSymbol
793
793
794
794
lazy val VCPrototypeType = ctx.requiredClassRef(s " dotty.runtime.vc.VCPrototype " )
795
- def VCPrototypeClass = VCPrototypeType .classSymbol.asClass
795
+ def VCPrototypeClass ( implicit ctx : Context ) = VCPrototypeType .classSymbol
796
796
797
- def vcPrototypeOf (vc : ClassDenotation ) = {
798
- val underlying = ValueClasses .valueClassUnbox(vc).info.classSymbol
799
- vcPrototype.getOrElse(underlying, vcPrototype(defn.ObjectClass ))
797
+ def vcRepresentationOf (vcReprs : Map [TypeName , TypeRef ], vc : ClassDenotation )(
798
+ undFn : ClassDenotation => Symbol )(implicit ctx : Context ): Symbol = {
799
+ val underlying = undFn(vc)
800
+ (if (underlying.isPrimitiveValueClass && vcReprs.isDefinedAt(underlying.name.asTypeName))
801
+ vcReprs(underlying.name.asTypeName) else vcReprs(defn.ObjectType .name)).classSymbol
800
802
}
801
803
802
- def vcCompanionOf (vc : ClassDenotation ) = {
803
- val underlying = ValueClasses .valueClassUnbox(vc).info.classSymbol
804
- vcCompanion.getOrElse(underlying, vcCompanion(defn.ObjectClass ))
805
- }
804
+ def vcPrototypeOf (vc : ClassDenotation )(implicit ctx : Context ) = vcRepresentationOf(vcPrototypeTypes, vc)(
805
+ ValueClasses .underlyingOfValueClass(_).classSymbol)
806
806
807
- def vcArrayOf (vc : ClassDenotation ) = {
808
- val underlying = ValueClasses .valueClassUnbox(vc).info.classSymbol
809
- vcArray.getOrElse(underlying, vcArray(defn.ObjectClass ))
810
- }
807
+ def vcDeepPrototypeOf (vc : ClassDenotation )(implicit ctx : Context ) = vcRepresentationOf(vcPrototypeTypes, vc)(
808
+ ValueClasses .deepUnderlyingOfValueClass(_).classSymbol)
809
+
810
+ def vcCompanionOf (vc : ClassDenotation )(implicit ctx : Context ) = vcRepresentationOf(vcCompanionTypes, vc)(
811
+ ValueClasses .underlyingOfValueClass(_).classSymbol)
812
+
813
+ def vcDeepCompanionOf (vc : ClassDenotation )(implicit ctx : Context ) = vcRepresentationOf(vcCompanionTypes, vc)(
814
+ ValueClasses .deepUnderlyingOfValueClass(_).classSymbol)
815
+
816
+ def vcArrayOf (vc : ClassDenotation )(implicit ctx : Context ) = vcRepresentationOf(vcArrayTypes, vc)(
817
+ ValueClasses .underlyingOfValueClass(_).classSymbol)
818
+
819
+ def vcDeepArrayOf (vc : ClassDenotation )(implicit ctx : Context ) = vcRepresentationOf(vcArrayTypes, vc)(
820
+ ValueClasses .deepUnderlyingOfValueClass(_).classSymbol)
811
821
812
822
def wrapArrayMethodName (elemtp : Type ): TermName = {
813
823
val cls = elemtp.classSymbol
0 commit comments