change intArrayOps and friends return types for efficiency#4297
change intArrayOps and friends return types for efficiency#4297xuwei-k wants to merge 1 commit intoscala:2.12.xfrom
Conversation
`ArrayOps.ofInt` is value class. but can not prevent allocation of new objects due to `intArrayOps` return type.
|
Wow, good catch! |
|
This is binary incompatible changes. Therefore I sent pull request to 2.12.x branch. |
|
Ah, yes, you're right -- I hadn't spotted that it's a partest linkage error. |
|
You could introduce a trait: trait PredefBinaryCompat {
def booleanArrayOps(xs: Array[Boolean]): ArrayOps[Boolean]
// ...
}
object Predef extends LowPriorityImplicits with PredefBinaryCompatThis will have the effect of generating bridge methods that are binary compatible with the current release of partest. After the next release of partest, this could be removed. |
|
We have the same problem with partest in #4285, but in that case there might not be an easy workaround. To discuss: is it really worth it to clutter up the standard library for this case? Or can we find a solution that skips those workarounds? |
|
Failing unit tests: |
|
@lrytz The clutter need only be temporary. We could release a new partest after the next milestone of 2.12, use that, and then remove the bridges. |
|
But wait, isn't the linkage error coming from partest-extras (a module in this project)? I suppose we're compiling that with the reference standard library but using the newly built one at runtime. |
|
I think it's the other way around, we build |
|
Ugh, I still don't get it, as the junit test classfiles were produced with: and run with: I don't see any inconsistencies there. |
|
Maybe scala-library is being pulled in through the partest dependency rather than the quick.library classpath in ant |
|
This fixed it for me locally, will rework PR and submit: <path id="quick.partest-extras.build.path">
<path refid="asm.classpath"/>
- <path refid="partest.classpath"/>
+ <restrict>
+ <path refid="partest.classpath"/>
+ <rsel:not><rsel:or>
+ <rsel:name name="scala-library*.jar"/>
+ </rsel:or></rsel:not>
+ </restrict> |
Suppress (transitive) dependency on external scala-library (through scala-partest). This caused trouble when binary compatibility was not preserved for scala-library, as in scala#4297. We already were doing this for `partest.compilation.path.noncore`, but we seem to have missed `quick.partest-extras.build.path`.
|
thanks! |
Suppress (transitive) dependency on external scala-library (through scala-partest). This caused trouble when binary compatibility was not preserved for scala-library, as in scala#4297. We already were doing this for `partest.compilation.path.noncore`, but we seem to have missed `quick.partest-extras.build.path`.
ArrayOps.ofIntis value class.but can not prevent allocation of new objects due to
intArrayOpsreturn type.