Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
ArraySeq map method boxing Java runtime primitives. #11761
So mapping from ArraySeq[Int] to ArraySeq[Int] maps to an underlying Array of AnyRef.
Unlike Arrays the ArraySeq map method doesn't take an implicit ClassTag parameter, so it doesn't have the data to create the correct underlying Array type. I presume this will also apply to all methods returning an ArraySeq, as they all seem to lack the ClassTag parameters, unlike the corresponding methods on raw Arrays.
This will apply to 2.13.0 and 2.13.1, but not earlier versions as ArraySeq introduced in 2.13.0.
there is discussion at https://contributors.scala-lang.org/t/is-arrayseq-fit-for-purpose/3736/7 about whether this may actually be necessary behavior
So to repeat the Opening post but with Doubles
So again we get boxing, but we shouldn't because Function1 has been specialised for Int and Double on both parameter and return types, and the type's are known at compile, and the specialisation works in my own experiment even when the map method is implemented in the base trait.
Boxing shouldn't occur even when using a Function2 for Int or Double as parameter or return type, as it is specialised, just not for Float on Argument type.